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

Find year +1

 
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
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Thu Jan 28, 2021 5:37 am    Post subject: Find year +1 Reply with quote

https://www.smarty.net/forums/viewtopic.php?p=90050&sid=ab8befb59387903e8ea230d93666c30b

In the above thread, I found this trick :-
Code:
{'Y'|date}


I am wondering, is there a way I can get the current year (not the day or month), and add 1 year to it. and assign it to a variable.

Or do i need to do that in PHP ?
Back to top
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Thu Jan 28, 2021 6:04 am    Post subject: Reply with quote

I've solved it in PHP - but would be good to know if possible in a template
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jan 29, 2021 9:21 pm    Post subject: Reply with quote

Write a wrapper around DateTime class.

Code:
<?=(new DateTime("today next year"))->format("c");
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Feb 12, 2021 8:04 pm    Post subject: Reply with quote

Try this:
Code:
{assign "woohoo" 'Y'|date:strtotime("next year")}
Test: {$woohoo}
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