最新消息:

PHP函数第22款:返回格式化(Y-m-d H:i:s)格式的时间GetDateTimeMk

PHP扩展函数 杨红伟 9657浏览 0评论

一:函数简介

虽然做这样一个时间很简单,但用一个函数,总是非常很方便的!这个函数返回(Y-m-d H:i:s)格式的时间。很方便,用用吧!

演示地址: http://www.ijquery.cn/phpfunction/GetDateTimeMk/demo1.php

下载地址: http://www.ijquery.cn/phpfunction/GetDateTimeMk/GetDateTimeMk.zip

二:函数应用

echo GetDateTimeMk(time());

返回的结果是:

2015-01-05 00:02:21

三:函数代码

注意:它依赖于MyDate时间函数

<?php
$cfg_cli_time = 8;
/**
 *  返回格式化(Y-m-d H:i:s)格式的时间
 *
 * @param     int    $mktime  时间戳
 * @return    string
 */
if (!function_exists('GetDateTimeMk')) {
	function GetDateTimeMk($mktime) {
		return MyDate('Y-m-d H:i:s', $mktime);
	}

}

/**
 *  返回格林威治标准时间
 *
 * @param     string  $format  字符串格式
 * @param     string  $timest  时间基准
 * @return    string
 */
if (!function_exists('MyDate')) {
	function MyDate($format = 'Y-m-d H:i:s', $timest = 0) {
		global $cfg_cli_time;
		$addtime = $cfg_cli_time * 3600;
		if (empty($format)) {
			$format = 'Y-m-d H:i:s';
		}
		return gmdate($format, $timest + $addtime);
	}

}


Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.ijquery.cn/wp-content/themes/d8-3.0/comments.php on line 17
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址