At the bottom of every answer box you see this
Use Markdown with GitHub-flavored code blocks
Please click the link, and properly post the code. code goes between 3 backticks
"```"
code
"```"
without apostrophes.
and use correct indentation.
Hi all,
I'm receiving the following string as input parameter to my application: 2017-07-11T20:15:00+02:00Z
I would like to save this date to UTC in MySQL but I keep losing the timezone (+02:00)...
$input = '2017-07-11T20:15:00+02:00Z'
$date= new Carbon($input);
When checking the object the timezone is present:
dd($date);
object(Carbon\Carbon)#96 (3) {
["date"]=>
string(26) "2017-07-11 20:15:00.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}
$hello->data_column = $date;
$hello->save();
After saving the object to MySQL, the wrong date is stored:
2017-07-11 20:15:00
Anyone has an idea what I'm doing wrong?
Thanks in advance!
Problem looks easy fixed by adding:
$date->setTimezone('UTC');
Please or to participate in this conversation.