Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date filter does not work with integer timestamps #3

Closed
speedmax opened this issue Nov 4, 2009 · 1 comment
Closed

date filter does not work with integer timestamps #3

speedmax opened this issue Nov 4, 2009 · 1 comment

Comments

@speedmax
Copy link
Owner

speedmax commented Nov 4, 2009

Hi there...

If I have a variable (say "my_timestamp") containing an integer timestamp, the following {{ my_timestamp | date }} does not work (it always displays Jan 1 1970).

The current code for this filter passes integers to strtotime, but that returns FALSE for integer input (at least on my system, php 5.3).

static function date($time, $format = ’jS F Y H:i’) {
if ($time instanceof DateTime)
$time = (int) $time->format(’U’);

return date($format, strtotime($time));

}

I would suggest this should be:

static function date($time, $format = ’jS F Y H:i’) {
if ($time instanceof DateTime)
$time = (int) $time->format(’U’);

if (!is_numeric($time)) $time = strtotime($time);

return date($format, $time);

}

original LH ticket

This ticket has 0 attachment(s).

@speedmax
Copy link
Owner Author

speedmax commented Nov 4, 2009

date filter does not work with integer timestamps

this is resolved in the master trunk

by Taylor luk

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant