Shipping Schedule (date and mktime)?
Posted: Fri Feb 11, 2005 10:44 am
I am a bit new to PHP. I need to have a calendar at the top of the page, and below shipping info. The client ships every friday, and in the thier words "These people can be retarded, so everything needs to be spelled out". So under the calendar I need to literally print:
february 1: Your order will be shipped on Friday february 11 (Est. arrival date is: february 12-15)
february 2: Your order will be shipped on Friday february 11 (Est. arrival date is: february 12-15)
And so on.
It needs to be dynamic because the client types this out line by line as of now. I have been Googling and manualing and such, and this is what I have come up with so far:
My initial concern was to get the days of the week, then calculate when friday is. I think I got that. Obviously I'm a bit of a hack, and I know the code is disgusting... my date loop is wrong (hence why it jumps from Feb 28 to march 29, incrementing by 1) so I need to:
1. Calculate how many days there are in the month
2. Print out each day of the week, with the ship date of the following friday, and estimated arrival date.
3. I deally have this and last months calendars at the top of the page with links to each ship date entry for each day. (Most likely just HTML anchors).
The trick is it must be generated on the fly, and by clicking next/last month regenerate based on that month. This is stumping me also. OK guys, I have done my homework, now theres a mind-block. Any suggestions?
february 1: Your order will be shipped on Friday february 11 (Est. arrival date is: february 12-15)
february 2: Your order will be shipped on Friday february 11 (Est. arrival date is: february 12-15)
And so on.
It needs to be dynamic because the client types this out line by line as of now. I have been Googling and manualing and such, and this is what I have come up with so far:
Code: Select all
<?php
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y"));
$nextyear = mktime(0, 0, 0, date("m"), date("d"), date("Y")+1);
$today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$firstday=01;
$td=date("d");
$nf=strtotime('next friday');
echo "<b>Today is ",date("l M.d",$today),"</b><br /><br />";
echo "<b>Next Friday is ",date("l M.d",$nf),"</b><br />";
echo "<b>Tomorrow = ",date("l M.d",$tomorrow),"</b><br />";
echo "<b>Last Month = ",date("l M.d",$lastmonth),"</b><br />";
echo "<b>Next Year = ",date("l M.d, Y",$nextyear),"</b><br /><br />";
if (date ('l') == 'Friday')
{
echo "Today is Friday<br />";
}
$time = time ();
for ($i = 0; $i < 7; $i++)
{
if (date ('l', $time += (60*60*24)) == 'Friday')
{
echo "Next Friday is on the ".date ("jS of F", $time), "<br/><br />";
break;
}
}
for ($x = 0; $x <30; $x++)
{
$today = mktime(0, 0, 0, date("m"), date("d") + $x, date("Y"));
$newday=$td + $x;
if($newday < 30){
echo date("l M.$newday",$today),"<br />";
}
}
?>1. Calculate how many days there are in the month
2. Print out each day of the week, with the ship date of the following friday, and estimated arrival date.
3. I deally have this and last months calendars at the top of the page with links to each ship date entry for each day. (Most likely just HTML anchors).
The trick is it must be generated on the fly, and by clicking next/last month regenerate based on that month. This is stumping me also. OK guys, I have done my homework, now theres a mind-block. Any suggestions?