Generating the days in a week : strftime « Date « PHP






Generating the days in a week

 
<?php

$now = time();

if (3 < strftime('%H', $now)) { $now += 7200; }

$today = strftime('%w', $now);

$start_day = $now - (86400 * $today);

for ($i = 0; $i < 7; $i++) {
  print strftime('%c',$start_day + 86400 * $i);
}
?>
  
  








Related examples in the same category

1.Checking for the day of the week
2.Format Characters Used by the strftime() Function for Day
3.Format Characters Used by the strftime() Function for Formatting Characters
4.Format Characters Used by the strftime() Function for Full Date and/or Time
5.Format Characters Used by the strftime() Function for Hour
6.Format Characters Used by the strftime() Function for Minute
7.Format Characters Used by the strftime() Function for Month
8.Format Characters Used by the strftime() Function for Second
9.Format Characters Used by the strftime() Function for Week
10.Format Characters Used by the strftime() Function for Year
11.strftime.php
12.Generating the days in a month
13.Finding days of the week, month, and year
14.Finding the current date and time
15.Printing a formatted date string with strftime()
16.Printing a formatted time string with other text
17.Printing a greeting or printing a form
18.Skip ahead one day to the Tuesday after the first Monday