Convert Unix Timestamp to Date/Time Format

Th TheMadMonk 02 Feb, 2017
Greeting, Bob, et al:

We have a report that currently displays a transaction id ('uxid'), which is a unix timestamp on the DB. Is there a way in CC to display this in human-readable form?

E.g., in custom code, I could use gmdate() or date() in PHP; if I could modify the MySQL query, I'd use something like FROM_UNIXTIME(uxid)

Thanks as always ~
Cliff
Gr GreyHead 02 Feb, 2017
Hi Cliff,

You could use the PHP strtotime() method in the listing PHP box to do the conversion.

Bob
Th TheMadMonk 06 Feb, 2017
Thanks, Bob -

So I'm in CC5, Front List, PHP Functions box, just in case that's not where you meant. I've tried multiple variations, but have been unable to et it right. Here's the latest syntax: (XtnArchived is a unix timestamp )

Transactions.XtnArchived:return $cell date("H:i:s", [Transactions][XtnArchived])


.... which results in the following error:

Parse error: syntax error, unexpected 'date' (T_STRING) in /var/www...

I gotta be close, right?

Thanks ~
Cliff
Gr GreyHead 07 Feb, 2017
Answer
Hi Cliff,

This bit has to be valid PHP
return $cell date("H:i:s", [Transactions][XtnArchived])
and it isn't. Please try
return date( "H:i:s",  $cell['Transactions']['XtnArchived'] );

Bob
This topic is locked and no more replies can be posted.