Date_format keyword modifier not working on timestamp


(Mark Nearhos) #1

Matrix Version: 5.5.0.2

I have a Data Record Set that includes a date value as a Unix timestamp. I want to modify it to another format, but the ^date_format modifier doesnt seem to work correctly.
For example if : ds__dateCommenced = 1553605200000
%ds__dateCommenced^date_format:Y% = 51201
%ds__dateCommenced^date_format:d M Y% = 16 Oct 51201

Whereas if I put that value into a Unix timestamp converter I get: GMT: Tuesday, 26 March 2019 13:00:00

The doco says the modifier works with timestamps.

Am I missing something ?


(John gill) #2

Unix timestamp is seconds since 1970 but that value must be milliseconds because it’s way too big. Just divide by 1000 before running it through date_format

%ds__dateCommenced^divide:1000^date_format:d M Y%


(Mark Nearhos) #3

Thanks John. All those zeros on the end should have given me a clue :slight_smile: