Returns a new DateTime object formatted according to the specified format:
<?php$date=date_create_from_format("jMY","15-Mar-2013");?>The date_create_from_format() function returns a new DateTime object formatted according to the specified format.
date_create_from_format( format,time,timezone);
parameter | describe |
---|---|
format | Required. Specifies the format to be used. The format parameter string can use the following characters: d - Day of the month, with leading zeros j - day of the month, without leading zeros D - day of the week (Mon - Sun) I - day of the week (Monday - Sunday) S - English suffix for day of the month (st, nd, rd, th) F - month name (January - December) M - month name (Jan - Dec) m - month (01 - 12) n - month (1 - 12) Y - year (e.g. 2013) y - year (e.g. 13) a and A - am or pm g - 12-hour clock without leading zeros h - 12-hour clock with leading zeros G - 24-hour clock without leading zeros H - 24-hour clock with leading zeros i - cents, with leading zeros s - seconds, with leading zeros u - microseconds (up to six numbers) e, O, P, and T - time zone identifiers U - Number of seconds elapsed since Unix epoch (space) # - One of the following delimiters:;,:,/,.,,,-,(,) ? - a random byte * - random bytes until next separator/number ! - Resets all fields to Unix epoch | - Resets all fields to Unix epoch if all fields have not been parsed yet + - If present, trailing data in the string will result in a warning, not an error |
time | Required. Specifies a date/time string. NULL represents the current date/time. |
timezone | Optional. Specifies the time zone for time . Defaults to the current time zone. |
Return value: | Returns a DateTime object if successful, or FALSE if failed. |
---|---|
PHP version: | 5.3+ |