获取当前日期,给出PHP中的时区? [英] Get current date, given a timezone in PHP?

查看:75
本文介绍了获取当前日期,给出PHP中的时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在PHP中获得Paul Eggert格式的时区( America / New_York )?

I want to get todays date given a time zone in Paul Eggert format(America/New_York) in PHP?

推荐答案

首先设置默认时区,然后获取日期,日期将在您指定的时区中: p>

Set the default time zone first and get the date then, the date will be in the time zone you specify :

<?php 
 date_default_timezone_set('America/New_York');
 $date= date('m-d-Y') ;
 ?>

http://php.net/manual/en/function.date-default-timezone-set.php

这篇关于获取当前日期,给出PHP中的时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆