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

Get remaining hours from two dates

 
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
kamalludinega
Smarty n00b


Joined: 12 Dec 2014
Posts: 3

PostPosted: Fri Dec 12, 2014 7:44 am    Post subject: Get remaining hours from two dates Reply with quote

Hello, i want to ask about how to get remaining hours from two dates
ex :

12-11-14 - 12-10-14

the result I expect is in hours and minutes so it should be
24h 00m

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


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Dec 12, 2014 1:31 pm    Post subject: Reply with quote

This is not Smarty question.
Code:
$ php -r 'print gmstrftime("%j %H:%M", strtotime("2012-11-14") - strtotime("2012-10-14"));'
032 00:00
Back to top
View user's profile Send private message
kamalludinega
Smarty n00b


Joined: 12 Dec 2014
Posts: 3

PostPosted: Sat Dec 13, 2014 8:02 am    Post subject: Reply with quote

sorry for not mention it on the question, yes this is a smarty question. The date is on smarty variable
Back to top
View user's profile Send private message
kamalludinega
Smarty n00b


Joined: 12 Dec 2014
Posts: 3

PostPosted: Sat Dec 13, 2014 10:35 am    Post subject: Reply with quote

ah I found another way,
I insert the smarty variable to javascript, and use jquery countdown
Code:
<script type="text/javascript">
          {literal}
          var dateTo =new Date("{/literal}{$custom[$cusstatus].date_to}{literal}");                                                        $('#defaultCountdown').countdown({until: dateTo,format:'DHM'});
           {/literal}
           </script>
[/code]
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Dec 13, 2014 8:56 pm    Post subject: Reply with quote

There's absolutely no reason to use {literal} in your example.
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