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.
display weekend dates
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
keithh0427
- Forum Newbie
- Posts: 15
- Joined: Thu Dec 16, 2004 8:17 am
-
keithh0427
- Forum Newbie
- Posts: 15
- Joined: Thu Dec 16, 2004 8:17 am
Got it figured out.
Thanks
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>";Take a look at the following code:
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
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";
?>This code segment should help you find a solution to your problem.
Ken
-
keithh0427
- Forum Newbie
- Posts: 15
- Joined: Thu Dec 16, 2004 8:17 am