note 105344 modified in function.strtotime by derick

From: Date: Sun, 14 Dec 2014 11:30:12 +0000
Subject: note 105344 modified in function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-201154@lists.php.net to get a copy of this message
[red.: This is a bug, and should be fixed. I have file an issue] This comment apply to PHP5+ We can now do thing like this with strtotime: <?php $weekMondayTime = strtotime('Monday this week'); ?> However this works based on a week starting Sunday. I do not know if we can tweak this PHP behavior, anyone know? If you want the timestamp of the start of the ISO Week (i.e. on Monday) as defined by ISO 8601, you can use this one liner: <?php $isoWeekStartTime = strtotime(date('o-\\WW')); // {isoYear}-W{isoWeekNumber} ?> You can also find out the start of week of any time and format it into an ISO date with another one liner like this: <?php $isoWeekStartDate = date('Y-m-d', strtotime(date('o-\\WW', $time))); ?> For more information about ISO-8601 and ISO week date: http://en.wikipedia.org/wiki/ISO_8601#Week_dates http://en.wikipedia.org/wiki/ISO_week_date --was-- This comment apply to PHP5+ We can now do thing like this with strtotime: <?php $weekMondayTime = strtotime('Monday this week'); ?> However this works based on a week starting Sunday. I do not know if we can tweak this PHP behavior, anyone know? If you want the timestamp of the start of the ISO Week (i.e. on Monday) as defined by ISO 8601, you can use this one liner: <?php $isoWeekStartTime = strtotime(date('o-\\WW')); // {isoYear}-W{isoWeekNumber} ?> You can also find out the start of week of any time and format it into an ISO date with another one liner like this: <?php $isoWeekStartDate = date('Y-m-d', strtotime(date('o-\\WW', $time))); ?> For more information about ISO-8601 and ISO week date: http://en.wikipedia.org/wiki/ISO_8601#Week_dates http://en.wikipedia.org/wiki/ISO_week_date http://php.net/manual/en/function.strtotime.php

« previous php.notes (#201154) next »