最新消息:

PHP函数第23款:返回格式化(Y-m-d)的日期GetDateMk

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

一:函数简介

正如第22款函数一样,有一个函数是非常方便的!这一款函数也依赖于 MyDate 函数。

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

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

二:函数应用

echo GetDateMk(time());

返回的结果是:

2015-01-04

三:函数源代码

<?php

$cfg_cli_time = 8;
/**
 *  返回格式化(Y-m-d)的日期
 *
 * @param     int    $mktime  时间戳
 * @return    string
 */
if ( ! function_exists('GetDateMk'))
{
    function GetDateMk($mktime)
    {
        if($mktime=="0") return "暂无";
        else return MyDate("Y-m-d", $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,您需要填写昵称和邮箱!

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