Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am testing my application in UK timezone (UTC) Dublin, Edinburgh, Lisbon, London.
The DST (Daylight saving time) in UK starts on Last Sunday of March i.e. 27-Mar-2016.
I am passing unix timestamp to Javascript Date object. It display normal date time but when UK DST is in effect, the time is one hour out

JavaScript
// s - unix timestamp
// ausOffset - Australian Timezone Offset i.e. +10:00(Canberra, Melbourne, Sydney)
// _clientOffset - client machine offset i.e. UK timezone (UTC) Dublin, Edinburgh, Lisbon, London

var _date = new Date(s * 1000);
var _Offset = ausOffset * 60 * 60000; 
var _dateTime = new Date(_date.getTime() + _Offset );
var _clientOffset = _date.getTimezoneOffset() * 60000; 
var _clientTime = new Date(_date.getTime() + _Offset + _clientOffset );
return _clientTime;

How can I avoid DST while creating datetime object in javascript.
Thanks in advance


What I have tried:

I tried to convert datetime in UTC timezone and added offset in it to get a specific date time.
Posted
Updated 2-Mar-16 17:12pm
v4
Comments
7045Jeegnesh 24-Feb-16 3:33am    
show us What u tried...

1 solution

Check out this js library:

Moment.js | Home[^]

and

Moment Timezone | Home[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900