substr((string)microtime(), 1, 6);that will give you: yyyy/mm/dd hh:ii:ss.uuuuuuhope this helps someone in need! This is much more obvious on the "zero-padded" results, but it's worth repeating.thanks all 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] = a day number 1 for Monday through 7 for Sunday... If you aren't careful, you can get stuck in a while loop comparing days of the week with something like: Most spreadsheet programs have a rather nice little built-in function called NETWORKDAYS to calculate the number of business days (i.e.
It replicates the functionality of Open Office's NETWORKDAYS function - you give it a start date, an end date, and an array of any holidays you want skipped, and it'll tell you the number of business days (inclusive of the start and end days! I've tested it pretty strenuously but date arithmetic is complicated and there's always the possibility I missed something, so please feel free to check my math.
The function could certainly be made much more powerful, to allow you to set different days to be ignored (e.g.
"skip all Fridays and Saturdays but include Sundays") or to set up dates that should always be skipped (e.g.
"skip July 4th in any year, skip the first Monday in September in any year"). Note that some formatting options are different from My SQL.
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.
It's common for us to overthink the complexity of date/time calculations and underthink the power and flexibility of PHP's built-in functions.
Consider 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.
L'intervalle de validité d'un timestamp va généralement du Vendredi 13 Décembre 1901 GMT au Mardi 19 Janvier 2038 GMT.
(Ces dates correspondent aux valeurs minimales et maximales des entiers 32 bits non-signés).
Cependant, avant PHP 5.1.0, cette intervalle va du au sur quelques systèmes (e.g. Vous pouvez faire afficher un caractère spécial dans la chaîne de format en le protégeant par un antislash.