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

is it possible to add time to a variable:

 
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 -> General
View previous topic :: View next topic  
Author Message
omexlu
Smarty Rookie


Joined: 13 Mar 2014
Posts: 27

PostPosted: Sun Nov 26, 2017 8:01 am    Post subject: Reply with quote

Hello,

I have one question is it possible to add time to a variable:
Code:
{$lastSportEntry.date|"+1 hour"|date_format:"%H:%M:%S"}


This don't work, is this possible?

Thanks Smile
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Nov 26, 2017 4:01 pm    Post subject: Reply with quote

http://php.net/manual/en/datetime.add.php
Back to top
View user's profile Send private message
omexlu
Smarty Rookie


Joined: 13 Mar 2014
Posts: 27

PostPosted: Sun Nov 26, 2017 4:30 pm    Post subject: Reply with quote

Thanks for your reply.

Yes sure but it is not possible to do this in template?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Nov 26, 2017 8:20 pm    Post subject: Reply with quote

It is possible, but complicated.
To make it less complicated, you could write a custom modifier for your case.
Also, please don't resurrect a ten-years-old topics anymore.
Back to top
View user's profile Send private message
omexlu
Smarty Rookie


Joined: 13 Mar 2014
Posts: 27

PostPosted: Wed Nov 29, 2017 1:07 pm    Post subject: Reply with quote

Hi,

Okay thank you.

How can i use second parameter in template with the costumer modifier?:
Code:
$smarty->registerPlugin("modifier","demoTPL", "demo");

function demo($first, $second)
{
    return $first . $second;
}

Code:

{$demo|demoTPL}


Thanks?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Nov 29, 2017 1:42 pm    Post subject: Reply with quote

Same as with any other modifier.
Code:
{param1|modifier:param2[…:paramN]}
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 -> General 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