Unix date to normal date

Hi there, how can I transform a unix date such as (1708205164.9331574) to a date in dd/mm/yyyy?

From a HTTP request I get the time in the above format, but I’d like to update my spreadsheet in an easier to read date. Is it possible to it within an expression rather than using a code node?

Thanks in advance!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I do not have my Laptop near me right now, so i xannot give you an example, but the Date & Time node should do the trick (;

hello @Ricky_Wolff

use this to transform the date:
{{ DateTime.fromMillis(Number($json.date)).toFormat('dd-MM-yyyy')}}

Thank you for the help! When using the expression “1708230881.6047385” results in “20-01-1970” instead of 16 feb 2024. Do you know why that is?

Try this instead

{{ DateTime.fromMillis(Number($json.date * 1000)).toFormat('dd-MM-yyyy') }}

unix is in seconds, javascript works with milliseconds so you need to multiply by 1,000 to covert to milliseconds


Ah, right. I thought the timestamp was 13 chars long.

For your case simplier to use DateTime.fromSeconds method or the approach, that @liam suggested

from seconds…duh im a bit dumb.
I can never keep the datatime stuff straight for JS.

Perfect! This worked. Thank you both for helping @liam & @barn4k

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.