[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Angular ui-grid Date format

Posted on 2016-10-02
7
Medium Priority
?
1,080 Views
Last Modified: 2016-11-13
Hi, I am trying to format the Date column in angular ui-grid(version 3.2.8) But it is not working.
The Dates are passing to getCellFormatDate function as Ex: 2016-09-27 15:18:26 But it is returning 0(zero). Plz suggest how to return it as
yyyy-MM-dd  

Grid columns definition
$scope.gridOptions = {
data: 'mydata',
enableRowSelection: true,
multiSelect: false,
enableColumnResize: true,
columnDefs: [
{ field: 'startDate', displayName: 'Date',type: 'date', 
cellTemplate: <div>{{grid.appScope.getCellFormatDate(row.entity.startDt}}</div>}]};

Open in new window

JavaScript code
$scope.getCellFormatDate = function(dt)
{
$scope.dtFormated = dt |'date:\'yyyy-MM-dd\'';
return $scope.dtFormatted;
};

Open in new window

Thanks
0
Comment
Question by:KavyaVS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 32

Assisted Solution

by:Pawan Kumar
Pawan Kumar earned 600 total points
ID: 41825782
I think format is not correct or supported.

Could you please try

date:'yyyy-MM-dd'

Also try

'date:'yyyy-MM-dd''

Please let me know if you still face after these.
0
 
LVL 32

Expert Comment

by:Pawan Kumar
ID: 41825783
Or may be full one

date:'yyyy-MM-dd HH:mm:ss Z'
0
 

Assisted Solution

by:KavyaVS
KavyaVS earned 0 total points
ID: 41826291
Hi,I tried 3 options provided. But none of them working. We need to escape the single quotes around the format and date should be in quotes otherwise it is showing the red squiggly line while coding itself. Thanks
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 27

Accepted Solution

by:
BigRat earned 1400 total points
ID: 41827851
According to your column definitions the TYPE of the date column is "date", but you're probably passing a string.

I don't think that $scope.dtFormated = dt |'date:\'yyyy-MM-dd\''; does a pipe operation. I would personally prefer, if I was to use a function like this to use one of the Javascript Date.xxx methods to format the date in the way you want. I suspect that the dt parameter is of type string. This will particularly be the case if the data comes from a server via JSON since JSON does not have a Date type.
0
 

Author Comment

by:KavyaVS
ID: 41847575
Yes. The data coming from the server via json. I tried to convert string Date as Date type. But it couldn't .It was undefined. Any suggestions plz.

Thanks
0
 
LVL 27

Assisted Solution

by:BigRat
BigRat earned 1400 total points
ID: 41848037
Could you please post the JSON which comes back from the server?
0
 

Author Closing Comment

by:KavyaVS
ID: 41885327
Thanks
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question