Jump to content

Date comparison help wth mktime


djones

Recommended Posts

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?

[code]
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;
[/code]
Link to comment
https://forums.phpfreaks.com/topic/4626-date-comparison-help-wth-mktime/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.