I have this DateTime format:
2020-08-27 19:00:00
and I want convert to this format:
Thu Aug 27 2020 19:00:00 GMT-0500 (hora estándar de Colombia)
my version php is 5 can i how to do thanks
I have this DateTime format:
2020-08-27 19:00:00
and I want convert to this format:
Thu Aug 27 2020 19:00:00 GMT-0500 (hora estándar de Colombia)
my version php is 5 can i how to do thanks
I'm gonna throw you a bone here because dates are hard. You can use the basic date
function and strtotime
to do everything you need, the trick is figuring out which formatting flags to use. You're gonna have a bad time with timezones, so be prepared to tear some hair out over that. Your date input doesn't have any timezone info, so your output is going to use whatever is set in your PHP instance.
Good luck.
<?php
$dateInput = '2020-08-27 19:00:00';
$time = strtotime($dateInput);
/*
Thu Aug 27, 2020 19:00 EDT-0400 (America/New_York)
The timezone will depend on what's set in your PHP instance. Look at date_default_timezone_set
*/
$output = date('D M j, Y H:i TO (e)', $time);
echo $output.PHP_EOL;
/*
Thu Aug 27, 2020 19:00 EDT-0400 (hora estándar de Colombia)
"hora estándar de Colombia" isn't a thing that php dates can do, so you have to hard code it.
Escape all non-format characters. Some are safe, but let's just nuke it from orbit. If this is more than
a one-off, write a function to escape the fancy timezone string.
*/
$output = date('D M j, Y H:i TO \(\h\o\r\a\ \e\s\t\á\n\d\a\r \d\e \C\o\l\o\m\b\i\a)', $time);
echo $output.PHP_EOL;