I am from Philippines. If ever I will use Carbon::now(), it catches my machine time and not the UTC time.
My config/app.php is:
'timezone' => 'UTC',
This is my code:
$log->dateRequest = Carbon::now();
If ever I will post a request at 9:00pm (Philippine time). It catches 21:00:00 , instead of 13:00:00 (from UTC).
Carbon::now returns the current date and time and Carbon:today returns the current date. This is a sample output.
php $timezone = date_default_timezone_get(); echo "The current server timezone is: " . $timezone; echo "<br />". date('m/d/Y h:i:s a', time()); $mytime = Carbon\Carbon::now(); echo "<br />".
UTC time in ISO-8601 is 09:05:16Z. Note that the Z letter without a space.
SimpleDateFormat f = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss"); f. setTimeZone(TimeZone. getTimeZone("UTC")); System. out.
In one of you questions you mentioned that you need to use multiple timezones in your app. So, you can add timezone dynamically:
Carbon::now('UTC')
Or use setTimezone('UTC')
method on existing date.
As stated in Carbon docs instantiation, try this:
$log->dateRequest = Carbon::now('UTC');
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