Kundello

Untitled

Mar 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * DATE: LOCAL FORMAT
  5. */
  6.  
  7. function getLocalDate($seconds, $format) {
  8. $date = new DateTime(gmdate("F jS, Y g:i A", $seconds));
  9. $date->setTimezone(new DateTimeZone($_SESSION["time_zone"]));
  10. return $date->format($format);
  11. }
  12.  
  13. if(!isset($_SESSION["time_zone"])) {
  14. $_SESSION["time_zone"] = "America/Los_Angeles";
  15. $geoip = json_decode(file_get_contents("http://freegeoip.net/json/".$_SERVER["REMOTE_ADDR"]), true);
  16. if(isset($geoip["time_zone"]) && in_array($geoip["time_zone"], timezone_identifiers_list())) {
  17. $_SESSION["time_zone"] = $geoip["time_zone"];
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment