note 94423 modified in function.strtotime by felipe
| From: | felipe@php.net | Date: | Sat, 07 Nov 2009 14:45:32 +0000 |
| Subject: | note 94423 modified in function.strtotime by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162478@lists.php.net to get a copy of this message | ||
I needed to generate timestamps for specific days of the week in a month (e.g. the 2nd wednesday or
the 3rd friday). After messing about with different syntax, I found this works pretty consistently:
<?php
strtotime('+0 week sun nov 2009'); // first sunday in nov 2009
strtotime('+1 week sun nov 2009'); // second sunday
strtotime('-1 week sun nov 2009'); // last sunday in oct 2009
?>
This is helping me considerably in parsing ical spec's RRULE sets for example.
--was--
I needed to generate timestamps for specific days of the week in a month (e.g. the 2nd wednesday or
the 3rd friday). After messing about with different syntax, I found this works pretty consistently:
strtotime('+0 week sun nov 2009'); // first sunday in nov 2009
strtotime('+1 week sun nov 2009'); // second sunday
strtotime('-1 week sun nov 2009'); // last sunday in oct 2009
This is helping me considerably in parsing ical spec's RRULE sets for example.
http://php.net/manual/en/function.strtotime.php