日期时间格式

发布于 2024-09-27 14:13:47 字数 118 浏览 1 评论 0原文

我想在 php 中将变量设置为特定日期,就像这样。如何在 php 中编写这个函数? jsmyStartDate = new Date('4 月 1 日,'+curYear+' 1:59:59');

i want to set a variable to a particular date like this in php..how to write this function in php? jsmyStartDate = new Date('April 1, '+curYear+' 1:59:59');

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无所谓啦 2024-10-04 14:13:47

你的意思是

<?php

$today = date("D M j Y  g:i:s e O");

echo $today;

// Thu Oct 14 2010 10:56:17 Europe/London +0100

或者为什么不只是

date('r');

do you mean

<?php

$today = date("D M j Y  g:i:s e O");

echo $today;

// Thu Oct 14 2010 10:56:17 Europe/London +0100

or why not just

date('r');

迷爱 2024-10-04 14:13:47

看看 php 手册中的 date ,你就差不多了正确的方法(只需将 R 替换为 eO ;) )。

看起来您希望日期采用 RFC2822 格式,在这种情况下,您也可以简单地使用 date("r")

take a look at date in the php manual, you're almost on the right way (just replace the R with eO ;) ).

it looks like you want the date to be in RFC2822-format, in this case you could also simply use date("r").

最偏执的依靠 2024-10-04 14:13:47

为什么这被否决了?它很简单,但仍然......

使用 date("DM j Y g:i:s \G\M\TO"); (最后的大 o )

Why is this voted down? Its simple but still...

use date("D M j Y g:i:s \G\M\TO"); (larg o at the end)

风情万种。 2024-10-04 14:13:47

在 php.net 网站上找到了这个 - http://php.net/manual/en/ function.date.php 就在底部

<?php

function zonedate($layout, $countryzone)
{
    if ( $countryzone >> 0 )
    {
        $zone = 3600 * $countryzone;
    }
    else
    {
        $zone = 0;
    }

    $date = gmdate($layout, time() + $zone);
    return $date;
}

$layout = "D M j Y g:i:s e O";
$countryzone = 5.5;

echo zonedate($layout, $countryzone);

?>

试试这样的东西?

Found this on the php.net site - http://php.net/manual/en/function.date.php right at the bottom

<?php

function zonedate($layout, $countryzone)
{
    if ( $countryzone >> 0 )
    {
        $zone = 3600 * $countryzone;
    }
    else
    {
        $zone = 0;
    }

    $date = gmdate($layout, time() + $zone);
    return $date;
}

$layout = "D M j Y g:i:s e O";
$countryzone = 5.5;

echo zonedate($layout, $countryzone);

?>

Try something like this?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文