I have a Creation date data property of the type date and time, I set that date using the following function:
and I updated it regularly depending on a variable that I have
It works as intended most of the time but sometimes the Creation date is set to the value in the image
No idea where that date is coming from in 1970, I wonder if anyone has any idea why is this occurring.
and thanks in advance
Thank you for posting to our Community!
It looks like the problem here is to do with the use of the moment library and Unix timestamps. The moment() function can be passed a Unix date, like how you do here with createdDate, but it can also be passed a number. When the function is passed a number, the parameter is interpreted as milliseconds and it returns the date x milliseconds after the Unix epoch (1st of January 1970). More about moment can be read here, in their documentation.
It seems here like the value 20240125 (or a similar value) has somehow been passed as a parameter, and it has calculated the date this many milliseconds after the epoch. 20,240,125 milliseconds is equal to around 5 hours and 37 minutes, which explains the output below, given as 5 hours 37 minutes and 20 seconds after the Unix epoch.
Is there another place where the variable “Today’s date” could be passed into this function instead of “Created Date”? This would explain why the output is given as a date in 1970, and why it has not been returned in the YYYYMMDD format.