Last active
January 20, 2016 09:47
-
-
Save sunitJindal/a4bb2b6a31869a7eec02 to your computer and use it in GitHub Desktop.
Revisions
-
sunitJindal revised this gist
Jan 20, 2016 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ // Local time zone is Asia/Kolkata with offset GMT +0530 var dt = "14/03/2016"; var dtz = "14/03/2016 +0130"; var tz = "+0130"; var df = "DD/MM/YYYY"; @@ -15,22 +15,22 @@ d1.format() // "2016-03-14T04:00:00+05:30" d2.format() // "2016-03-14T00:00:00+05:30" d3.format() // "2016-03-14T00:00:00+01:30" d4.format() // "2016-03-13T20:00:00+01:30" d1.toDate() // Mon Mar 14 2016 04:00:00 GMT+0530 (IST) d2.toDate() // Mon Mar 14 2016 00:00:00 GMT+0530 (IST) d3.toDate() // Mon Mar 14 2016 04:00:00 GMT+0530 (IST) d4.toDate() // Mon Mar 14 2016 00:00:00 GMT+0530 (IST) -
sunitJindal revised this gist
Jan 20, 2016 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,10 @@ var tz = "+0130"; var df = "DD/MM/YYYY"; var dfz = "DD/MM/YYYY Z"; var d1 = moment(dtz,dfz); // date string with time zone var d2 = moment(dt,df); // date string without timezone var d3 = moment(dtz,dfz).utcOffset(tz); // date string with time zone. Apply UTC offset after moment is created var d4 = moment(dt,df).utcOffset(tz); // date string without time zone. Apply UTC offset after moment is created d1.format() // "2016-03-14T04:00:00+05:30" -
sunitJindal created this gist
Jan 20, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ // Local time zone is Asia/Kolkata with offset GMT +0530 var dt = "14/02/2016"; var dtz = "14/03/2016 +0130"; var tz = "+0130"; var df = "DD/MM/YYYY"; var dfz = "DD/MM/YYYY Z"; var d1 = moment(dtz,dfz); var d2 = moment(dt,df); var d3 = moment(dtz,dfz).utcOffset(tz); var d4 = moment(dt,df).utcOffset(tz); d1.format() // "2016-03-14T04:00:00+05:30" d2.format() // "2016-02-14T00:00:00+05:30" d3.format() // "2016-03-14T00:00:00+01:30" d4.format() // "2016-02-13T20:00:00+01:30" d1.toDate() // Mon Mar 14 2016 04:00:00 GMT+0530 (IST) d2.toDate() // Sun Feb 14 2016 00:00:00 GMT+0530 (IST) d3.toDate() // Mon Mar 14 2016 04:00:00 GMT+0530 (IST) d4.toDate() // Sun Feb 14 2016 00:00:00 GMT+0530 (IST)