Link to home
Start Free TrialLog in
Avatar of KavyaVS
KavyaVS

asked on

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
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
SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Or may be full one

date:'yyyy-MM-dd HH:mm:ss Z'
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KavyaVS
KavyaVS

ASKER

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KavyaVS

ASKER

Thanks