Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Convert local time to UTC format

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 114
    Comment on it

    Hello Guys,

    Today we will learn how to convert the local time period into UTC format :

    We will create a function with offset and time as parameter.Below is the code:

    function
      convertToUTC($DateTimeZone,$offset){
      $DateTimeZone='2015-10-28 03:11:00';
      $offset='+5:30';
      $date = new DateTime($DateTimeZone.$offset);
      $date->setTimezone(new DateTimeZone('UTC')); // +05
      $date=$date->format('Y-m-d H: i: s');
      echo  $date; 
       } 

    Following will convert the local time to the UTC format.Enjoy!!

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: