Skip to content
Advertisement

PHP UTC String to date

I have a problem. In my code I have the following line:

JavaScript

The goal is to get the previous and next hour, so I tried this:

JavaScript

But then the I get the following result:

JavaScript

Because of my timezone (+1) the RunDateTimeGMT0 gets converted to a date of my timezone. I want the following result:

JavaScript

How can I keep the date object UTC?

Advertisement

Answer

You can use the Carbon library. after import this library you should parse the date with this :

JavaScript

in this link, you could see the documentation of Carbon. Although, maybe you should to use this method :

JavaScript

I hope your problem solve with these lines, If another issue occurred you can ask.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement