Parameters

The format used in date (e.g. the same as
used in strftime()). Note that some of the format
options available to strftime() may not have any
effect within strptime(); the exact subset that are
supported will vary based on the operating system and C library in
use.

For more information about the format options, read the
strftime() page.

Notes

Note: This function is not
implemented on Windows platforms.

Note:

Internally, this function calls the strptime()
function provided by the system's C library. This function can exhibit
noticeably different behaviour across different operating systems. The
use of date_parse_from_format(), which does not
suffer from these issues, is recommended on PHP 5.3.0 and later.

If you need strptime but are restricted to a php version which does not support it (windows or before PHP 5), note that MySQL since Version 4.1.1 offers (almost?) the same functionality with the STR_TO_DATE function.

It says "Parse a time/date generated with strftime()" but that's not entirely correct -- While strptime("2006131", "%Y%W%u") works as expected, strptime("2006131", "%G%V%u") returns false instead of reversing the equivalent - and unambiguous - strftime() usage. I suspect that's because glibc doesn't support that. Anyway, this docu page fails to mention that apparently not all format components supported by strftime() can be used with strptime().

This is not because of what platform you're using or what format strings glibc supports. This is simply because strptime returns years SINCE 1900 (as documented above) and mktime expects a year in the format returned by date('Y') - which is the full 4 digits.

Therefore, if you parse a date with strptime and want to give it to mktime, you have to pass in ($parsed_time['tm_year'] + 1900) as the year parameter to mktime(), not just $parsed_time['tm_year'].

On some systems, particularly those of BSD lineage (such as FreeBSD and MacOS X), the tm_wday and tm_yday fields are only initialized if requested explicitly (that is, if the %a/%A/%u/%w and %j formats are specified), while others such as Linux and Solaris will calculate them automatically.

<?php
//This turns non-standard but often used "datetime" string
//like '20060810084251' into nice formatted date
//'Thursday, 10 August 2006 08:42:51 CEST'
//note, that strptime returns day of year counting from 0, so
//you need to put 1 as month number to get appropriate
//month for the daycount. for 2006 strptime for unknown
//reason returns 106, so I simply add 1900

//echo $tdname."<br>"; //echo $rep;$datstart =$td; /* the starting date *///$rep = 12; /* number of future dates to display */ $nod = 1; /* number of days in the future to increment the date */$nom = 0; /* number of months in the future to increment the date */$noy = 0; /* number of years in the future to increment the date */