note 11153 deleted from ref.datetime by felipe

From: Date: Mon, 10 Dec 2007 17:38:01 +0000
Subject: note 11153 deleted from ref.datetime by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133174@lists.php.net to get a copy of this message
Note Submitter: vincentv at thevoid dot demon dot nl ---- Some general date functions. function sub($timestamp, $seconds,$minutes,$hours,$days,$months,$years) { $mytime = mktime(1+$hours,0+$minutes,0+$seconds,1+$months,1+$days,1970+$years); return $timestamp - $mytime; } function add($timestamp, $seconds,$minutes,$hours,$days,$months,$years) { $mytime = mktime(1+$hours,0+$minutes,0+$seconds,1+$months,1+$days,1970+$years); return $timestamp + $mytime; } function dayOfWeek($timestamp) { return intval(strftime("%w",$timestamp)); } function daysInMonth($timestamp) { $timepieces = getdate($timestamp); $thisYear = $timepieces["year"]; $thisMonth = $timepieces["mon"]; for($thisDay=1;checkdate($thisMonth,$thisDay,$thisYear);$thisDay++); return $thisDay; } function firstDayOfMonth($timestamp) { $timepieces = getdate($timestamp); return mktime( $timepieces["hours"], $timepieces["minutes"], $timepieces["seconds"], $timepieces["mon"], 1, $timepieces["year"]); } function monthStartWeekDay($timestamp) { return dayOfWeek(firstDayOfMonth($timestamp)); } function weekDayString($weekday) { $myArray = Array( 0 => "Sun", 1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat"); return $myArray[$weekday]; } function stripTime($timestamp) { $timepieces = getdate($timestamp); return mktime( 0, 0, 0, $timepieces["mon"], $timepieces["mday"], $timepieces["year"]); } function getDayOfYear($timestamp) { $timepieces = getdate($timestamp); return intval($timepieces["yday"]); } function getYear($timestamp) { $timepieces = getdate($timestamp); return intval($timepieces["year"]); } function dayDiff($timestamp1,$timestamp2) { $dayInYear1 = getDayOfYear($timestamp1); $dayInYear2 = getDayOfYear($timestamp2); return ((getYear($dayInYear1)*365 + $dayInYear1) - (getYear($dayInYear2)*365 + $dayInYear2)); } hope they are usefull to you. - Vincent

« previous php.notes (#133174) next »