cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain difference btw 2 timestamp?

aleung
Contributor III

Any idea how to obtain seconds, minutes, or hours between 2 timestamp?

1 ACCEPTED SOLUTION

In the above example just dont use the quotes, instead send as JSON object!! Otherwise you will get the warning from the platform at runtime.

Date.now().toLocaleDateString({“timeZone”:“PST”, “format”:“yyyy-MM-dd”})

View solution in original post

13 REPLIES 13

aleung
Contributor III

thx, that works. On the similar note, anyway to get PST datetime with the Date.now() function?

In the documentation, there is this example:

Creating and Formatting a Date in a Specific Timezone
Expression:
Date.now().toLocaleDateString(‘{"timeZone":"PST", “format”:“yyyy-MM-dd”}’)

Description: The expression will create the current date time in the PST timezone and format its output into a string in the form of yyyy-MM-dd.


Diane Miller
Community Manager

In the above example just dont use the quotes, instead send as JSON object!! Otherwise you will get the warning from the platform at runtime.

Date.now().toLocaleDateString({“timeZone”:“PST”, “format”:“yyyy-MM-dd”})

Can anyone help me to fix, datatype issue during date format conversion?

Date.parse($GTA_DATE_LAST_CHG.toString()).toLocaleDateTimeString({“format”:“dd/MM/YYYY HH:mm:ss”})

It gives result result 11/11/2009 17:03:37 but which has string datatype. But while loading into target facing an data type issue.

Instead of string datatype I need to convert as date-time datatype. but with the same above format.

Date.parse is already parsing it to a date object. Is that not good for you? What is the need for toLocaleDateTimeString again?

Am I missing something here?