Convert epoch to a readable format

I have a rule that collects the data I need and stores it in these variables in these formats:

$WeatherLastRain = 2023-02-23T12:25:00.000Z
$WeatherLastLightning = 1677245080000

All I want to do is convert the variables into something like “Feb 23” and display it a readable date format on a tile or super tile.

I’ve been digging around here for a while but much of the info is about doing calculations on two different dates.

Have you read through the Date Functions in Rule Expressions help article?

The $WeatherLastLightning looks like it’s already in milliseconds, so it could be used with formatDate() directly:

formatDate(1677245080000, 'MMM D')

The $WeatherLastRain appears to be an ISO 8601 formatted date, so the formatDate() should be able to implicitly parse it as well.

myDate = "2023-02-23T12:25:00.000Z"
formatDate(myDate, 'MMM D')

Ok, that solved it for me. I ended up using a rule action to collect the dates and then another rule action to format the variable in a human readable format.


Thanks for your support!