Page 1 of 1
display weekend dates
Posted: Wed Dec 22, 2004 7:42 pm
by keithh0427
A newbie question.
I'm trying to display the Friday-Sunday dates at the top of a report and I only have Friday in the database as Y-m-d.
The format I'm attempting to get is "Dec 24-26, 2004". I can get "Dec 24, 2004" OK, but when I use mktime() I can't figure out how to get only the day from that date into the text I'm looking for.
Any help would be greatly appreciated.
Posted: Wed Dec 22, 2004 8:06 pm
by John Cartwright
have you visited [php_man]date[/php_man]??
Posted: Wed Dec 22, 2004 8:16 pm
by keithh0427
yes. I'm trying to figure it out and having trouble. that's why I posted here. I'm still working on it.
$weekendSun= mktime(0, 0, 0, $weekendFri("m") , $weekendFri("d")+2, $weekendFri("Y"));
Just having trouble displaying in the correct format.
Posted: Wed Dec 22, 2004 8:48 pm
by keithh0427
Got it figured out.
Code: Select all
$date_input = $weekendDate_selected;
list($year, $month, $day) = split('ї/.-]', $date_input);
$weekendDate_selected = $month . "-" . $day . "-" . $year;
$weekendFri=date("M-d-Y", mktime(0, 0, 0, $month, $day, $year));
$date_input=date("M-d-Y", mktime(0, 0, 0, $month, $day+2, $year));
list($month2, $day2, $year2) = split('ї/.-]', $date_input);
$weekendSun = $month2 . "-" . $day2 . "-" . $year2;
echo "<font face=arial size=5><center>Worldwide Marriage Encounter</center></font>";
echo "<font face=arial size=3><center>Weekend List</center></font>";
echo "<font face=arial size=3><center>for: ", $month2, " ", $day, "-", $day2, ", ", $year, "</center></font>";
Thanks
Posted: Wed Dec 22, 2004 8:49 pm
by kenrbnsn
Take a look at the following code:
Code: Select all
<?
$fri = date('M j, Y',strtotime('this friday'));
$sun = date('M j, Y',strtotime($fri . ' +2 days'));
echo 'Friday: ' . $fri . "<br>\n";
echo 'Sunday: ' . $sun . "<br>\n";
?>
I know some people frown on using the
strtotime function, but I like it since it will translate an (almost) english phrase to a date/time.
This code segment should help you find a solution to your problem.
Ken
Posted: Wed Dec 22, 2004 8:52 pm
by keithh0427
Thanks! I like that solution better than the one I worked on.