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
Angular

Avatar of undefined
Last Comment
KavyaVS
SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Or may be full one

date:'yyyy-MM-dd HH:mm:ss Z'
SOLUTION
Avatar of KavyaVS
KavyaVS

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
ASKER CERTIFIED SOLUTION
Avatar of BigRat
BigRat
Flag of France image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
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
Avatar of BigRat
BigRat
Flag of France image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of KavyaVS
KavyaVS

ASKER

Thanks
Angular
Angular

Angular is a JavaScript open-source web application framework used to develop single-page applications. It aims to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) and model–view–view-model (MVVM) architectures, along with components commonly used in rich Internet applications. Angular is the front-end part of the MEAN stack, together with Node.js runtime, Express.js backend framework and MongoDB database.

1K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo