Mike6979865
Posts: 0
Joined: Fri Jul 11, 2014 3:53 pm

Convert _CreatedAt - Javascript Assistance

Thank you, it worked. I had to also change var goalTimeZone = -7; to var goalTimeZone = -14; to get the Pacific Standard Time (California Time)

Regards, and thank you so much for your help.

Mike6979865
Posts: 0
Joined: Fri Jul 11, 2014 3:53 pm

Convert _CreatedAt - Javascript Assistance

Hi,
When it's daylight saving, I have to manually adjust the time in the code by one hour. I'm thinking to apply the following:

Get current month
If month is between 3 and 11 then goal time zone = -14
else - 16

Can you please help me with that? Does that seem like a solution? The problem is that daylight savings change each year...

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Convert _CreatedAt - Javascript Assistance

Hi Mike,

Yes it's possible. But i guess you need to narrow daylight period criteria..

Here is a requested code:

pre

var stringDate = value;
var arrDate = stringDate.split(/[- :]/);
var date = new Date(arrDate[0], arrDate[1]-1, arrDate[2], arrDate[3], arrDate[4]);

//You can change timezone here;
var goalTimeZone = -16;

var month = date.getMonth() + 1;
if(month 3 && month < 11)
goalTimeZone = -14;

date = new Date(date&#46;getTime() + (goalTimeZone * 3600 * 1000));
console&#46;log(date);
return date&#46;toUTCString()&#46;replace(/GMT/gi, "");

/pre

Regards.

Return to “Issues”