getting timestamp for first day of current week
| From: | Olav Mørkrid | Date: | Tue, 03 Jul 2007 18:19:52 +0000 |
| Subject: | getting timestamp for first day of current week | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-258169@lists.php.net to get a copy of this message | ||
hello
how do i get the TIMESTAMP for the FIRST DAY of the CURRENT WEEK (ie.
monday 00:00:00)?
i tried using strtotime("monday"), but:
- when i use it on a monday, i get monday THIS WEEK
- when i use it on tuesday thru sunday, i get monday NEXT WEEK
i tried "last monday", "monday this week", "this monday", etc. but
nothing helps.
this code proves the issue (2 july is a monday, 8 july is a sunday)
for($d=2; $d<=8; $d++) {
$time = strtotime("$d july 2007");
$date = date("Y-m-d", strtotime("monday", $time));
echo "$date<br/>\n";
}
is this a bug, or a locale issue? at any rate, how do i get monday 00:00:00?
thanks!