Exemple #1
0
 /**
  * Returns the timestamp for the most recent (previous) occurance of [month].
  *
  * @param	timestamp
  * @param	int			the month of year
  * @return	timestamp
  */
 public static function previousMonth($ts = null, $month = sfTime::JANUARY)
 {
     // default to now
     if ($ts === null) {
         $ts = sfDateTimeToolkit::now();
     }
     // get offsets from january
     $offset1 = date('m', $ts);
     $offset2 = $month;
     // adjust if date wraps into last year
     $offset1 += $offset1 > $offset2 ? 0 : 12;
     return sfTime::subtractMonth($ts, $offset1 - $offset2);
 }