Hi,
I have a field called ‘sent’ which is a 10 digit time stamp.
How to I convert this back to a humanised date/time?
I thought the following which is part of a repeat might work but I’m clearly missing something;
Many thanks for helping
CK
Hi,
I have a field called ‘sent’ which is a 10 digit time stamp.
How to I convert this back to a humanised date/time?
I thought the following which is part of a repeat might work but I’m clearly missing something;
Many thanks for helping
CK
The formatDate() formatter you’re using looks correct.
Do you get any console errors in the Dev Tools of the browser?
If you added the formatter through code, it might be worth using the Wappler UI to add a formatter to the page (even if you remove it afterwards). The formatter javascript need to be included on the page and this process should get Wappler to add them to your page for you. If using NodeJS you may need to save both the layout and content page before redeploying.
Hi Ben,
Thanks for your reply.
I checked that the formatter script is loaded and it is, the only error I get from Dev Tools is:
DevTools failed to load source map: Could not load content for https://mydomain.com/dmxAppConnect/maps/dmxAppConnect.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
Ah, just thought it is a timestamp, you will probably have to convert it to a date first using .toDate()
so
sent.toDate().formatDate('dd-MM-yyyy')
Tried that but no joy, Dev Tools now not showing any errors…
what do you get on the page with just sent
?
Using just the ‘sent’ field I get all the 10 digit timestamp numbers as follows:
1639378801
1641297001
etc
etc
When I run this through a php script:
<?php $t=1641297001; echo($t . "I get a result from the number so I know they seem to be correct, just looks Wappler is not converting the number back to a date…
Where is the sent variable coming from? Is it really a number or is it maybe a string with a number.
Try this little workarround:
sent.toNumber().toDate().formatDate('dd-MM-yyyy')
For debugging you can also change the expression to:
json(sent)
And to see if the formatters work correctly you can try:
1641297001.toDate().formatDate('dd-MM-yyyy')
From what I can tell it’s just a text field with a 10 digit number in it.
Your first solution has worked and my page is now returning dates as desired, thank you very much for your idea and help.
I’d now like to be able to select records based on a date range, can you suggest a tutorial or solution I can use for this?