Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

timestamp global format

posted by netpork 7 years ago

I have a recordset with some data and timestamp. Default displayed date format is 'Y-m-d H:i:s', how can I globally format that, so, doing some localization, thus, display a date in this format 'd-m-Y H:i:s' without doing it in a loop manually calling fTimestamp->format() for every record.

I have tried using fTimestamp::registerFormatCallback() and fTimestamp::registerUnformatCallback() without success since if I do date formatting in fTimestamp::registerFormatCallback(), fRecordSet::build(), where I do some date comparison, then does not yield any records.

$rhr = fRecordSet::build(

			'rhr_datetime>=' => $from,
			'rhr_datetime<=' => $to,
			'rhr_usr_id=' => $userId
			'rhr_datetime' => 'desc'

Huh, I hope I am clear enough!? :)

The Y-m-d H:i:s format is used in the toString() method of fTimestamp, and as you've found, quite a bit of Flourish relies on that functioning properly.

You aren't going to be able to get away with not calling format() if you want a different format from the ISO-8601 style. You can, however, define a standard format to use throughout your app - fTimestamp#DefiningFormats. This gives you the ability to control the format from a single place instead of having to update code in lots of different places if you want to tweak your default format.

posted by wbond 7 years ago