PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 13, 2022

[FIXED] How to convert any time zone into UTC using Laravel

 January 13, 2022     laravel, php, php-carbon     No comments   

Issue

I want to convert the user's time, eg. 08:45 P.M, to UTC time zone. How can I do that?

if ($request->open_at)
{
  $time = Carbon::parse($request->open_at)->toUTCString();
  dd($time);
  $query->whereTime('open_at', '>=', $time);
}

Solution

Use this PHP approach:

$time = new DateTime("08:45 P.M");
$time ->setTimezone(new DateTimeZone("UTC"));
echo $time ->format("Y-m-d H:i:s e");


Answered By - Faizan Ali
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing