Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

shared.make_timestamp plugin

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
tamole
Smarty n00b


Joined: 30 Jun 2004
Posts: 1
Location: Lithuania

PostPosted: Wed Jun 30, 2004 11:16 pm    Post subject: shared.make_timestamp plugin Reply with quote

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
View user's profile Send private message Visit poster's website
Frunnik
Smarty n00b


Joined: 08 Jul 2004
Posts: 1

PostPosted: Thu Jul 08, 2004 1:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP