|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
tamole Smarty n00b
Joined: 30 Jun 2004 Posts: 1 Location: Lithuania
|
Posted: Wed Jun 30, 2004 11:16 pm Post subject: shared.make_timestamp plugin |
|
|
i use unix timestamps on my website, and when i want to format the timestamt with date_format, i get a date like 8849-02-08 00:00:00
the problem is that the $string, given to the funkction strtotime is not checked if its a string or may be a timestamp... so i changed the line
[php:1:f78c5b0512]
$time = strtotime($string);
[/php:1:f78c5b0512]
into
[php:1:f78c5b0512]
if ( !is_int( $string ) ) $time = strtotime( $string );
[/php:1:f78c5b0512] |
|
Back to top |
|
Frunnik Smarty n00b
Joined: 08 Jul 2004 Posts: 1
|
Posted: Thu Jul 08, 2004 1:12 pm Post subject: |
|
|
First off all my englisch is verry bad.
But i had the same problem but i fixed it on a other way.
Code: |
<?php
$Smarty->register_function('date', 'display_date');
?>
|
Function
Code: |
<?php
function display_date($input){
extract($input);
return date($format, $time);
}
?>
|
Template
Code: |
{date time=4665468493 format="H:i d-m-Y"}
<!-- or string... -->
|
Now you can use the function date in the templates...
http://www.php.net/date |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|