Anyone got a function that will please strtotime()but accept the format as input?
strtotime()
For example, I need to convert yyyymmddto a timestamp, or perhaps yyyyddmm. Therefore, I would like to indicate the format used. Also Im on Windows , therefore, is strptime()not a parameter.
yyyymmdd
yyyyddmm
strptime()
The PHP 5 DateTimeclass has a createFromFormatmethod that does what you need.
DateTime
createFromFormat
However, it requires PHP 5.3, so it is not always an option (for now).
, mktime...
// Assumes yyyy-mm-dd function fromdate($date) { $d = explode("-", $date); return mktime(0, 0, 0, $d[1], $d[2], $d[0]); }