doutuoji8418 2015-09-30 21:15
浏览 39

如何根据从php返回的日期对象在jquery中创建一个新的Date对象?

I have a php script that returns date in tokyo in a following format:

Thu, 01 Oct 2015 06:10:09 +0900

I already passed it to my jquery script with ajax and now store it in local variable

var myTime = 'Thu, 01 Oct 2015 06:10:09 +0900

Now I want to create a new Date() object with that data, so then I can have an actual date from tokyo on my webpage without using local client's timezone. How can I do that?

  • 写回答

1条回答 默认 最新

  • duaeim2874 2015-09-30 21:54
    关注

    If your PHP code returns just that string:

    <?PHP echo "Thu, 01 Oct 2015 06:10:09 +0900"; ?>
    

    Then in your jQuery ajax return:

    function(data) 
    {
        var myDate = new Date(data.trim());
        //...
    }//..
    

    Example: of the raw string in jsfiddle JsFiddle

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料