首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何格式化时间戳以只显示没有时间的日期

如何格式化时间戳以只显示没有时间的日期
EN

Stack Overflow用户
提问于 2014-01-29 10:53:31
回答 2查看 504关注 0票数 0

嗨,我在MySQL中存储了时间戳,并且在更新CURRENT_TIMESTAMP上有这个属性,当我回显它时,给我日期和时间,我怎么能只显示日期,而不需要时间。这一次显示数据被包含在数据库中的日期和时间--我有以下代码

代码语言:javascript
复制
if (php_sapi_name() == 'apache') {
    // if our web server is apache
    // we get check HTTP
    // If-Modified-Since header
    // and do not send image
    // if there is a cached version

    $ar = apache_request_headers();
    if (isset($ar['If-Modified-Since']) && // If-Modified-Since should exists
        ($ar['If-Modified-Since'] != '') && // not empty
        (strtotime($ar['If-Modified-Since']) >= $image_time)) // and grater than
        $send_304 = true;                                     // image_time
}


if ($send_304)
{
    // Sending 304 response to browser
    // "Browser, your cached version of image is OK
    // we're not sending anything new to you"
    header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ts).' GMT', true, 304);

    exit(); // bye-bye
}

// outputing Last-Modified header
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $image_time).' GMT',
        true, 200);

// Set expiration time +1 year
// We do not have any photo re-uploading
// so, browser may cache this photo for quite a long time
header('Expires: '.gmdate('D, d M Y H:i:s',  $image_time + 86400*365).' GMT',
        true, 200);

我试着删除H:i:s,但是这并没有改变到输出,我如何才能改变它呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-01-29 10:58:05

删除H:i:s将改变输出,我怀疑您更改了错误的内容。

d/m/Y H:i:s将输出01/01/2014 00:00:00

d/m/Y将输出01/01/2014

票数 1
EN

Stack Overflow用户

发布于 2014-01-29 11:00:11

删除H:i:s函数中的参数.gmdate

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21428857

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档