Using Javascript to change a Date Field for country specific export
Hi,
I currently have an Appointment date 'date' field in my leads app where I book my initial appointment with my customers.
I have a category field labelled 'Create Appointment confirmation Email' which I then use with Zapier to trigger an email to be sent to the customer with a conformation of their appointment.
I have to have an additional field in my App called 'Appointment Conformation Output' where I've used Javascript to convert the date to my UK version, i.e 27th March 2015 at 10am.
I noticed this morning when I made an appointment with a customer and clicked the category field to trigger the email that when the email went to the customer the time was an hour earlier than what was showing in my date field and inevitably my calender as well.
This is what it looks like in PODIO.
This is the javascript I've been using
moment(@Appointment Date).format("dddd MMM Do YYYY hh.mm a")
I've spoken to PODIO support and they have advised me to look at this
http://momentjs.com/timezone/docs/
I'm not a coder :) But am big on business automation.
Can some please help?
-
Hi Lee,
it's not a coding issue, it's a logical issue :)
The date 31.03. in your date field is AFTER DST-change on 29th. The calculation with moment () always takes the current time at the moment you create that field (or the moment one of the values in the formula changes). Change the date in the date field to 28.03. and you'll see that the time in the calculation field will also be 11:00.
To avoid this DST-issue set the time zone in your calculation:
moment(@Appointment Date).tz('Europe/London').format("dddd MMM Do YYYY hh.mm a")
Rainer
rg@delos-consulting.com -
Thanks a lot!
It solved a problem for me too with all day events, where I am calculating the date to use in the title. When the start date field was set to 14-05-2017 00:00, the date was calculated to 13-05-2017.
But with the help of the tz time zone function, it solved this problem. So the calculation I'm using now is this:
moment(@Dato).tz('Europe/Copenhagen').format("DD-MM-YYYY")
Best regards,
Please sign in to leave a comment.
Comments
3 comments