943,621 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1711
  • PHP RSS
Dec 20th, 2008
0

create date??

Expand Post »
In my variable
$time=2008-12-19 14:12:10 this value is in database
and
duration to find next date is 21157 in seconds
$event_length=21157

Suppose today's date is 2008-12-21
How to find next date by using $time value??
$timestamp = strtotime("$time");
$etime = strtotime("+$event_length seconds", $timestamp);

$next_time = date('Y:m:d H:i:s', $etime); //here date get's today's date 
So my problem is How to find next time and date??
Similar Threads
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
Dec 20th, 2008
0

Re: create date??

in your example, You have already converted your date to a timestamp and have the event length in seconds, so just add the seconds to the timestamp. Here, Try This...
PHP Syntax (Toggle Plain Text)
  1. $timestamp = strtotime("$time");
  2. $etime = $timestamp+$event_length;
  3. $next_time = date('Y:m:d H:i:s', $etime); //here date get's today's date
Hope It Helps.
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
PomonaGrange is offline Offline
67 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: populate select list from multiple Mysql tables
Next Thread in PHP Forum Timeline: Display mysql data





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC