Possible Duplicate:
PHP: convert date format yyyy-mm-dd => dd-mm-yyyy [NOT IN SQL]
Hope everyone is having a great holiday.
I have a date in this format: 23-12-2011
and would like to reverse it into US format 2011-12-23
.
Does anyone know how I can do this in PHP? Is there any function for breaking strings up?
In the below example, we have date 2019-09-15 in YYYY-MM-DD format, and we will convert this to 15-09-2019 in DD-MM-YYYY format. $orgDate = "2019-09-15"; $newDate = date("d-m-Y", strtotime($orgDate));
How convert date from yyyy-mm-dd to dd-mm-yyyy format in PHP? Answer: Use the strtotime() Function You can first use the PHP strtotime() function to convert any textual datetime into Unix timestamp, then simply use the PHP date() function to convert this timestamp into desired date format.
Select the column of dates you want to convert to another locale. Press Ctrl+1 to open the Format Cells. Select the language you want under Locale (location) and click OK to save the change.
Definition and Usage The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.
$date = DateTime::createFromFormat('d-m-Y', '23-12-2011');
echo $date->format('Y-m-d');
Voila. Check out PHP5s datetime class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With