Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. $carbon = new CarbonCarbon($dateasstring);
  2. $local = $carbon->timezone($localTimeZone);
  3.  
  4. // example from artisan tinker:
  5. [1] > $utc = new CarbonCarbon('2014-01-05 12:00:00');
  6. // object(CarbonCarbon)(
  7. // 'date' => '2014-01-05 12:00:00',
  8. // 'timezone_type' => 3,
  9. // 'timezone' => 'UTC'
  10. // )
  11. [2] > $warsaw = $utc->timezone('Europe/Warsaw');
  12. // object(CarbonCarbon)(
  13. // 'date' => '2014-01-05 13:00:00',
  14. // 'timezone_type' => 3,
  15. // 'timezone' => 'Europe/Warsaw'
  16. // )
  17.  
  18. private function totimezone($utc){
  19. $usertz = Session::get('timezone');
  20. $carbon = new Carbon($utc, 'UTC');
  21. $carbon->timezone = new DateTimeZone($usertz);
  22. return $carbon;
  23.  
  24. }
  25.  
  26. private function toutc($local){
  27. $usertz = Session::get('timezone');
  28. $carbon = new Carbon($local, $usertz);
  29. $carbon->timezone = new DateTimeZone('UTC');
  30. return $carbon;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement