JSON Date Conversion

My query returns dates in the following format /Date(1425859200000+0000)/
Timestamp in milliseconds from 1970 I believe.
I need to convert to 01/02/2015… Is there a formatter built into Wappler to handle this or a combination of format conversions?

I’ve tried:
{{myDate.substring(6, 19).toNumber().toDate()}}
{{myDate.substring(6, 19).toNumber().toDateString()}}

Thanks Mim

try {{myDate.substring(6, 16).toNumber().toDate()}}, you need a unix timestamp which is the number of seconds from 1970, so 3 numbers less.

1 Like

Much appreciated @patrick

Hi @patrick
Whilst I can do this with client side formatting using
myDate.substring(6, 16).toNumber().toDate().formatDate('dd/MM/yyyy')

I don’t seem to be able to do this within a Server Connect Set Value action
I get as far as myDate.substr(6, 16.toNumber()) but then formatting this to a date format doesn’t show a value.

Any ideas?
Thanks

You have the formatters nested wrong. myDate.substr(6, 16.toNumber()) should be myDate.substr(6, 16).toNumber().

Hi @patrick
That may be wrong, but if I use your syntax no value is returned. I have to use myDate.substr(6, 16.toNumber()) I am using NodeJS if that helps you check.

So lets say I get a value without the /date e.g 1451692800000+00 how do I format that as a date value?

Did you get a chance to take a look at this @patrick
I appreciate it was a busy date yesterday with v4.0.

I can send you a link to the API endpoint if you want to check.
Its just a date as follows /Date(1425859200000+0000)/

Thanks.

Any ideas @patrick??

From what i understand in this post all you need in your server action is:

myDate.substr(6, 10).toNumber().formatDate('dd/MM/yyyy')
1 Like