Jump to content

Date Difference


jeeva

Recommended Posts

try this
[code]
<?php
$start = "20-2-2007";
$end = "3-3-2007";

$st =  explode("-",$start);
$newStart = strtotime("$st[2]-$st[1]-$st[0]"); //rearange date so it is Y-m-d/coverts to timestamp
$fi = explode("-",$end);
$newEnd = strtotime("$fi[2]-$fi[1]-$fi[0]");
do
{
echo date("d-m-Y",$newStart);
echo ", ";
$newStart = strtotime("+1 day", $newStart);

}while ($newStart < $newEnd)


?>
[/code]

it prints out all the dates from the start date to the end date
Link to comment
https://forums.phpfreaks.com/topic/34969-date-difference/#findComment-164932
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.