php时区转换转换函数

yipeiwu_com6年前PHP代码库

复制代码 代码如下:

/*
 * 时区转换
 */

function toTimeZone($src, $from_tz = 'America/Denver', $to_tz = 'Asia/Shanghai', $fm = 'Y-m-d H:i:s') {
    $datetime = new DateTime($src, new DateTimeZone($from_tz));
    $datetime->setTimezone(new DateTimeZone($to_tz));
    return $datetime->format($fm);
}

相关文章

php对二维数组进行相关操作(排序、转换、去空白等)

技巧提示: array_keys($array) //返回所有键名 array_values($array) //返回所有键值 $result=array_rever...

如何实现php图片等比例缩放

通过文章给出的源代码可实现针对图片的等比缩放生成缩略图的功能,非常实用的技巧哦。 新建文件index.php,需要在统计目录下有个图片为pic.jpg(可根据源码进行更改图片的名称) 源...

php的字符串用法小结

1 求长度,最基本的 $text = "sunny day"; $count = strlen($text); // $count = 9 2 字符串截取 截取前多少个字符 $artic...

php中opendir函数用法实例

本文实例分析了php中opendir函数用法。分享给大家供大家参考。具体如下: opendir语法:opendir(path,context) 目录,功能说明:打开目录句柄,opendi...

PHP 查找字符串常用函数介绍

一、strstr — 查找字符串的首次出现 string strstr ( string $haystack , mixed $needle [, bool $before_needle...