Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
51
rated 0 times [  53] [ 2]  / answers: 1 / hits: 31781  / 8 Years ago, thu, april 7, 2016, 12:00:00

I'm looking for a suitable way to convert a timestamp from UTC to IST using JavaScript DateTimeStamp 20160108120040.



The timestamp comes from an XML in my body request.


More From » javascript

 Answers
171

First thing, take a look at JavaScript date formats and convert your input date accordingly, then you shoud take a look to the methods available in JavaScript for date manipulation (no external library required). It's pretty easy to do something like this:



var dateUTC = new Date(yourInputDateInASuitableFormat);
var dateUTC = dateUTC.getTime()
var dateIST = new Date(dateUTC);
//date shifting for IST timezone (+5 hours and 30 minutes)
dateIST.setHours(dateIST.getHours() + 5);
dateIST.setMinutes(dateIST.getMinutes() + 30);

[#62654] Tuesday, April 5, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raveno

Total Points: 453
Total Questions: 92
Total Answers: 92

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
raveno questions
;