Exemple #1
0
 /**
  * Returns the timestamp for the most recent (previous) occurance of [day].
  *
  * @param	timestamp
  * @param	int			the day of week
  * @return	timestamp
  */
 public static function previousDay($ts = null, $day = sfTime::SUNDAY)
 {
     // default to now
     if ($ts === null) {
         $ts = sfDateTimeToolkit::now();
     }
     // get offsets from sunday
     $offset1 = date('w', $ts);
     $offset2 = $day;
     // adjust if date wraps into last week
     $offset1 += $offset1 > $offset2 ? 0 : 7;
     return sfTime::subtractDay($ts, $offset1 - $offset2);
 }