M
maflatoun
Hi,
I have the following function to convert UTC time to Local time. It
works perfect for GMT- (Minus) time zones however it provides incorrect
results for GMT+(Plus) time zones?
// Format to local time from UTC
function formatToLocalTimeDate(inDate) {
var today = new Date();
var inDateMod = new Date(inDate);
offSet = today.getTimezoneOffset();
if(offSet < 0) {
inDateMod.setMinutes(inDateMod.getMinutes()+offSet);
} else {
inDateMod.setMinutes(inDateMod.getMinutes()-offSet);
}
return inDateMod;
}
Can anyone help with this? Or does anyone have a code that would do
this for me?
Thanks
Maz.
I have the following function to convert UTC time to Local time. It
works perfect for GMT- (Minus) time zones however it provides incorrect
results for GMT+(Plus) time zones?
// Format to local time from UTC
function formatToLocalTimeDate(inDate) {
var today = new Date();
var inDateMod = new Date(inDate);
offSet = today.getTimezoneOffset();
if(offSet < 0) {
inDateMod.setMinutes(inDateMod.getMinutes()+offSet);
} else {
inDateMod.setMinutes(inDateMod.getMinutes()-offSet);
}
return inDateMod;
}
Can anyone help with this? Or does anyone have a code that would do
this for me?
Thanks
Maz.