Working with timestamps

Hi All,

In my database, I have a timestamp for the record creation which is stored as and passed to weweb as a unix timestamp. What is the best way to convert it to dd/mm/yyyy?

1 Like

I would convert it in the backend. What backend are you using?

1 Like

Hey Edward, Thanks for replying. I am using Xano.

1 Like

when you get the data from the database, create a variable in Xano that contains the date and format it. Then you can add it to the response at the end and return it together

2 Likes

That’s a great shout. Thanks @Edward

2 Likes

In case, here is a quick video as the format can be a bit tricky. Its d/m/Y for UK format (11/06/2022)

video

2 Likes

Personaly, I wouldn’t do the conversion to a string in the backend.

Timestamp are probably easier to handle for sorting and other calculation (add days or years, calculate time differences,…). And if, at some point, you need to format the date in different format accross you app, having a formatted string to start with will not help.

I would rather avise to create a custom formula that converts the timestamp to a date.

This require a bit of javascript, but nothing too complex I’d think - although there are a few step for the actual conversion (timestamp to milliseconds, milliseconds to Date, Date to formatted string).

Here is a step by step tutorial : Convert a Unix Timestamp to a Date in Vanilla JavaScript


Now, if the webweb teams is reading this : a NoCode formula to format date would be great. don’t you think ?

Yep, working on it :grinning:

2 Likes