Jump to content


Photo

Date comparison help wth mktime


  • Please log in to reply
1 reply to this topic

#1 djones

djones
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts
  • LocationWinston-Salem, NC

Posted 10 March 2006 - 06:47 PM

I'm pulling $date_created from the database. It is in this format: March-10-2006-10-55-22. I need to echo the $date_created plus 5 days from it. All works ok BUT I need to keep the original hours, minutes, and seconds. How can I do this? How do I add variables into the mktime below?

echo "Date Created: ".$date_created."<br />";

$split_date = split("-", $date_created);

//EX of $date_created :: date("F-j-Y-g-i-s") = March-10-2006-10-55-22

$second = $split_mydate[5];   // :22
$minute = $split_mydate[4];   // :15:
$hour = $split_mydate[3];   // 10:

$year = $split_mydate[2];   // 2006
$day = $split_mydate[1]; // 10
$month = $split_mydate[0];  // March


//Need to keep the original hours, minutes, and seconds from above. How do I add it in mktime?
$tomm  = date("F-j-Y-g-i-s", mktime(0, 0, 0, date("m"), date("d")+5, date("Y")));
echo "<br/>".$tomm;


#2 djones

djones
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts
  • LocationWinston-Salem, NC

Posted 10 March 2006 - 07:33 PM

I finally figured it out. Please close.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users