For example using a 24 hour notation without leading zeros is the option '%G' in PHP but '%k' in My SQL. When using dynamically generated date formatting string, be careful to generate the correct options for either PHP or My SQL.$now will return the same (the server's current) Unix time stamp regardless which timezone your user is in. This is sure that the information you shared is clearly identive and fabulous for keeping it in minds.
For those of us still needing it, here is simple hack to get the job done.private function get Weeknumber Sunday First Day Of Week(\Date Time Interface $date) I've been flicking through the comments looking for some succinct date code and have noticed an alarming number of questions and over-burdened examples related to date mathematics.One of the most useful skills you can utilize when performing date math is taking full advantage of the UNIX timestamp.The UNIX timestamp was built for this kind of work.A function not using php's date() function that will also account for this small anomaly in leap years: While is_leapyear_working will not return true for the few non-leap years divisible by four I couldn't tell you if this is more or less efficient than using php's date() as an even earlier poster suggested: Thanks to tcasparr at gmail dot com for the great idea (at least for me) ;)I changed the code a little to replicate the functionality of date_parse_from_format, once I don't have PHP 5.3.0 yet. Hope you don't mind changing your code tcasparr at gmail dot com./******************************************************* * Simple function to take in a date format and return array of associated * formats for each date element * * @return array * @param string $str Format * * Example: Y/m/d g:i:s becomes * Array * ( * [year] = The following function will return the date (on the Gregorian calendar) for Orthodox Easter (Pascha).
Note that incorrect results will be returned for years less than 1601 or greater than 2399.Prior to PHP 5.6.23, Relative Formats for the start of the week aligned with PHP's (0=Sunday,6=Saturday).Since 5.6.23, Relative Formats for the start of the week align with ISO-8601 (1=Monday,7=Sunday)."skip July 4th in any year, skip the first Monday in September in any year"). If you see the number 86400 in a date calculation, think very hard before deciding that it is correct. In many places, some days have only 82,800 seconds and some have 90,000. Assuming that now plus 86,400 seconds is equivalent to some time tomorrow can sometimes be wrong.It might actually be the day after tomorrow or still today. Note that some formatting options are different from My SQL. This is sure that the information you shared is clearly identive and fabulous for keeping it in minds.An example of this relates to a comment made by james at bandit-dot-co-dot-en-zed.