Need help displaying time frame (months, weeks, days) betwee

General discussions related to php

Moderators: macek, egami, gesf

techman
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Apr 18, 2013 2:50 pm

Need help displaying time frame (months, weeks, days) betwee

Postby techman » Thu Apr 18, 2013 3:18 pm

I'm looking to develop PHP code for the following application, similar to a countdown timer.
I want to compute the difference between the current date and the date of a future event (happens to be 1/7/2014).
Easy to do. But I want to display the difference or time between the current date and this future event as follows
---- Event is x months and y weeks and z days from today
I believe the best approach is to start with the datediff function, but it's the display output portion that gets tricky
I would appreciate some help or direction. Thanks

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Need help displaying time frame (months, weeks, days) be

Postby johnj » Thu Apr 18, 2013 7:33 pm

You need tobe sure what datediff will produce. For e.g. If the output of datediff is seconds then to convert that to minutes, you need to divide the datediff output value by 60. Similarly you need to do it for days, months, weeks etc. take a look at the examples in the php manual. http://php.net/manual/en/function.date-diff.php


Return to “PHP General”

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 1 guest