Parse the time/date generated by strftime():
<?php$format="%d/%m/%Y %H:%M:%S";$strf=strftime($format);echo("$strf");print_r(strptime($strf,$ format));?>The strptime() function parses the time/date generated by strftime().
Note: This function cannot be implemented on Windows platform!
strptime( date,format);
parameter | describe |
---|---|
date | Required. The string to parse (for example: as returned by strftime()). |
format | must. Specify the format to be used in dates: %a - abbreviation for day of the week name %A - the full name of the day of the week %b - abbreviation for month name %B - Full month name %c - Preferred date and time representation %C - century number (year divided by 100, range 00 to 99) %d - day of the month (01 to 31) %D - time format, same as %m/%d/%y notation %e - day of the month (1 to 31) %g - similar to %G notation, but without the century %G - 4-digit year corresponding to ISO week number (see %V) %h - same notation as %b %H - hour, using 24-hour clock (00 to 23) %I - hour, using 12-hour clock (01 to 12) %j - Day of the year (001 to 366) %m - month (01 to 12) %M - points %n - newline character %p - am or pm corresponding to the given time value %r - time notation for am and pm %R - 24-hour time notation %S - seconds %t - tab tab character %T - current time, same notation as %H:%M:%S %u - Numeric representation of the day of the week (1 to 7), Monday = 1. Warning: Sunday = 1 on Sun Solaris systems %U - the number of weeks included in the current year, starting with the first Sunday as the first day of week 1 %V - The number of weeks (01 to 53) in ISO 8601 format contained in the current year. Week 1 represents the first week of the year, which must have at least four days, and Monday is the first day of the week. %W - the number of weeks included in the year, starting with the first Monday as the first day of week 1 %w - Day of the week as a decimal number, Sunday = 0 %x - Preferred date representation without time %X - Preferred time representation without date %y - year representation without century digits (range 00 to 99) %Y - Year representation including a digit representing the century %Z or %z - time zone name or abbreviation %% - output a % character |
Return value: | If successful the function returns an array with the parsed date. Returns FALSE on failure. The meaning of the key names of the returned array is as follows: [tm_sec] - Number of seconds in the current minute (0-61) [tm_min] - Number of minutes in the current hour (0-59) [tm_hour] - hour since midnight (0-23) [tm_mday] - Day of the month (1-31) [tm_mon] - How many months have passed since January (0-11) [tm_year] - How many years have passed since 1900 [tm_wday] - How many days have passed since Sunday (0-6) [tm_yday] - How many days have passed since January 1 this year (0-365) [unparsed] - Parts of the date that are not recognized by the specified format |
---|---|
PHP version: | 5.1+ |