Tip - Altering get requests - Date / Time

Just wanted to share my struggle to convert Epoch to human readable time.

Working on a auction site where the REST API returns time in epoch format (1696838700), this is how you can do it so Divhunt can interpret it:

return new Date(${value->get('ends_at')} * 1000).toLocaleString('sv-SE', {
    year: 'numeric',
    day: '2-digit',
    month: 'long',
    hour: '2-digit',
    minute: '2-digit',
    timeZone: 'CET'
})

Change the “toLocaleString('sv-SE” to your location and it should work :slight_smile:

Hope this helps someone else :+1:t3:

2 Likes

@MixxMaster

Considering that there is no documentation for this, just wow, nicely done!