1

I need to display local time in city New Your for everyone user, who visit my web site. How I can do it?

1
  • You would visit php.net and Google. Here, Google this "local time new york php" Jan 21, 2015 at 15:58

1 Answer 1

8

Put this at the top of your php.

date_default_timezone_set("America/New_York");

You can also do this.

$date = new DateTime();
$date->setTimezone(new DateTimeZone('America/Detroit'));
$fdate = $date->format('Y-m-d H:i:s');`

$fdate will print the appropriate time in new york with date.

All the timezones here - http://php.net/manual/en/timezones.america.php

Not the answer you're looking for? Browse other questions tagged or ask your own question.