Convert a date into a string for different timezones

I am trying to convert a date into a string for different timezones, is that possible in Codeless?

For example:
DateNow as a string in GMT, EST or PST. If the current datetime is Fri 9 Apr 2021 14:00 GMT,

I would like to print eg. Fri 9 Apr 2021 10:00 EDT or Fri 9 Apr 2021 7:00 PDT,

Is this possible?

Hi @Andreas_Marinopoulos !

At the current moment there is not such blocks in Codeless logic. Could you please decribe your use-case so maybe we could suggest your bypass?

Regards, Andriy

Sure, I am sending messages to people in different timezones regarding future appointments.

I use a timestamp for the actual sending of the message so that is not a problem.

But in the text of the message, I want to remind the people that their appointment is on Fri 9 Apr 2021 10:00 EDT or Fri 9 Apr 2021 7:00 PDT. As they are in different timezones, I cannot use a timestamp or a UTC time.

Your colleague has suggested something that solves the opposite problem here

But now I am in fact looking for the opposite, to express different strings for a timestamp.

I am having trouble with dates and I need a bit more documentation or point towards a youtube video or sth.

When I try this


as per @olhadanylova 's suggestion, I receive this "2021-02-11T20:00:00.000Z" which I believe is incorrect.

The other conversions don’t work either. Can you confirm?

Is the question about how to convert a timestamp to a different timezone? If not, then what? I am a bit confused about what the problem is.

Yes, I am trying to create a string of a date in a different timezone.

When I perform calculations, I use a timestamp and I don’t care about timezones, but here my use case is sending a message to a user’s email (which needs to contain the date in the email message using the user’s local timezone).

eg. I can start from a string in PST as above and end with a string in EST.

I see. We’d need to update the following block to accept the timezone information:

Until then, you’d need to compose the string manually. I cannot think of any other way, unfortunately. I will open an internal ticket to make that change.

Regards,
Mark

Thanks for that, may I also ask what the Set Date Property block does?
image

It uses the following function:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate
where the first connector (date) is the date object and the second connector (value) is what’s passed into the setDate function call.

Hi. @Andreas_Marinopoulos

We have added the option to convert the time from local to different time zones. The new block is found in the Date section. You can find available options here.
As an example, on my screen I am converting the time from local to US/New York:

Regards,
Marina

1 Like

This is excellent, thanks!

Thanks works perfect also for me!
Mario

1 Like