Can anyone let me know how to convert a string
to a date
Object with UTC time zone in ExtJs?
String is "2015-10-07T23:59:00"
. I would like to get the same in Date Object without changing the timezone.
Can anyone let me know how to convert a string
to a date
Object with UTC time zone in ExtJs?
String is "2015-10-07T23:59:00"
. I would like to get the same in Date Object without changing the timezone.
First of all, your date string does not have a timezone.
When you make a JavaScript date object from a string, there are two possible outcomes you could expect:
In this case, you want to use
new Date("2015-10-07 23:59:00")
with plain javascript (note the missingT
), orExt.Date.parse("2015-10-07T23:59:00","c");
.In this case, you want to use
new Date("2015-10-07T23:59:00")
.Of course, whenever you output the date, you have to get the date in the correct time zone as well. The console/toString will usually show it in local time. JavaScript does provide
getUTC...
methods if you require other time zones.You see, using Time Zones with JavaScript is a painful experience. I would recommend to try moment.js if you need full time zone support.
try
it will parse date in GMT timezone, Ext.date.parse use the current timezone instead
You can use
Ext.Date.parse
.It gives Date Object as output.It syntax is:For Example: