Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
20
rated 0 times [  24] [ 4]  / answers: 1 / hits: 49575  / 9 Years ago, wed, september 2, 2015, 12:00:00

I am referring to http://momentjs.com/timezone/docs/#/using-timezones/



In example, its given for below locations :



moment.tz.add([
'America/Los_Angeles|PST PDT|80 70|0101|1Lzm0 1zb0 Op0',
'America/New_York|EST EDT|50 40|0101|1Lz50 1zb0 Op0'
]);


I am not sure of IST values as its given for :



{
name : 'America/Los_Angeles', // the unique identifier
abbrs : ['PDT', 'PST'], // the abbreviations
untils : [1414918800000, 1425808800000], // the timestamps in milliseconds
offsets : [420, 480] // the offsets in minutes
}


Could someone help in adding IST object to this?


More From » date

 Answers
10

The easiest way is to just use one of the files that includes time zone data from the moment-timezone home page, such as moment-timezone-2010-2020.js or moment-timezone-all-years.js (or the minified versions).



You can however add just a single zone if you prefer. You can find the zone's packed string within the data files listed above. For India, the full zone definition is:



moment.tz.add(Asia/Calcutta|HMT BURT IST IST|-5R.k -6u -5u -6u|01232|-18LFR.k 1unn.k HB0 7zX0);
moment.tz.link(Asia/Calcutta|Asia/Kolkata);


You may or may not need the link, depending on what exactly you're doing.



Note that I assumed that by IST you mean India Standard Time, and not Irish Standard Time or Israel Standard Time. Those zones would have different data, of course.



Also, since India has been on UTC+5:30 since 1942, you may just wish to use a fixed offset - which would eliminate the need to use moment-timezone. Just use the utcOffset function in moment. For example, both of the following will return the current time in India.



moment().utcOffset(+05:30).format()


or



moment().utcOffset(330).format()

[#65210] Monday, August 31, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;