|
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 |
Demerzel Smarty Rookie
Joined: 31 Jan 2010 Posts: 26
|
Posted: Fri Sep 03, 2010 12:22 pm Post subject: Converting data to months |
|
|
I have two dates 1283205600 1314827999. I can display them using
Code: | {$date|date_format:"%Y/%m/%d"} |
But I would like to count month diference between them.
Using php I tried to do
But having one int number I have no idea how to convert it to month. I don't see way to use php explode.
How can i count number of months? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Sep 03, 2010 1:45 pm Post subject: |
|
|
Do you need it exact? if you do $time2-$time1 you will get the number of seconds between them. A month is approximately 86400*30 seconds, so if you divide it: ($time2-$time1)/86400*30
you should get close. use floor() or ceil() around that figure to get a whole number. |
|
Back to top |
|
Demerzel Smarty Rookie
Joined: 31 Jan 2010 Posts: 26
|
Posted: Sun Sep 05, 2010 9:27 pm Post subject: |
|
|
Thanks, I soloved it in php
Code: | $time=$end-$start;
$time=floor($time/60/60/24/7/4); |
|
|
Back to top |
|
imdumbnotsmarty Smarty n00b
Joined: 20 Aug 2010 Posts: 4
|
Posted: Tue Sep 07, 2010 10:27 am Post subject: |
|
|
Yes that works. |
|
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
|