Angular ui-grid Date format

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

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

Who is Participating?
BigRatConnect With a Mentor Commented:
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 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.
Pawan KumarConnect With a Mentor Database ExpertCommented:
I think format is not correct or supported.

Could you please try


Also try


Please let me know if you still face after these.
Pawan KumarDatabase ExpertCommented:
Or may be full one

date:'yyyy-MM-dd HH:mm:ss Z'
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

KavyaVSConnect With a Mentor Author Commented:
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
KavyaVSAuthor Commented:
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.

BigRatConnect With a Mentor Commented:
Could you please post the JSON which comes back from the server?
KavyaVSAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.