You need to sign in to do that
Don't have an account?
SFDC n12
method to convert date time to date format in javascript
Hi,
I want to convert a datetime field to date field in javsscript
var date=record.LastModifiedDate;
what is the method i can use to convert it
Thanks
I want to convert a datetime field to date field in javsscript
var date=record.LastModifiedDate;
what is the method i can use to convert it
Thanks
now its displaying in this format
Fri May 09 2014 10:30:50 GMT+0530 (India Standard Time)
what i need is not the time only the date
from
2013-01-28T17:09:21.000Z
to
2013-01-28
Unfortunately there doesn't seem to be any standard way to do this with the Date object directly in javascript
Fri May 09 2014 10:30:50 GMT+0530 (India Standard Time)
var date = new Date(record.LastModifiedDate);
date.toISOString().slice(0,10);
To get YYYY-MM-DD format from your last post you would do something similar to:
For the format, you can follow the guidelines from the SimpleDateFormat class in Java here: http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
Note: If you're field is of a "Date" type, instead of "Datetime" then you will need to convert it to a Datetime class.
var date = new Date(record.LastModifiedDate);
date.toISOString().slice(0,10);
You do not get "2014-05-09" in the console?
its displaying in the below format only
Fri May 09 2014 10:30:47 GMT+0530 (India Standard Time)
Date field value recieved from callback response: 2018-03-25T00:00:00.000Z
After casting that value to new Date(field) as suggested by pcon: Sat Mar 24 2018 17:00:00 GMT-0700 (Pacific Daylight Time)
--> this was making me lose a day due to time conversion
I solved this by using substring on the field value recieved from the response before passing it back to the component.