zoukankan      html  css  js  c++  java
  • 时间戳 unix时间 javascript时间

    <?php
    echo "本机所在的时区:".date("T")."<BR />";
    echo "PHP时间戳(UNIX秒):".mktime()."<BR />";
    echo "PHP时间(本地格式化后):".date("Y-m-d H:i:s")."<HR />";
    ?>
    <script language="javascript">
    <!--
    var d;
    function myDate(timestamp) {
     d = new Date(timestamp);
     var jstimestamp = (d.getFullYear())+"-"+(d.getMonth()+1)+"-"+(d.getDate())+" "+(d.getHours())+":"+(d.getMinutes())+":"+(d.getSeconds());
     return jstimestamp;
    }
    var phptimestamp = <?=mktime()?>;
    var jstimestamp = myDate((phptimestamp*1000));
     
    document.writeln("PHP传递给Javascript时间:" + phptimestamp + "<BR>");
    alert("PHP传递给Javascript时间:" + phptimestamp);
     
    document.writeln("Javascript将PHP传递来的时间乘以1000后的时间戳:" + phptimestamp*1000 + "<BR>");
    alert("Javascript将PHP传递来的时间乘以1000后的时间戳:" + phptimestamp*1000);
     
    document.writeln("Javascript自身格式化PHP传递来乘以1000后的时间戳:" + d + "<BR>");
    alert("Javascript自身格式化PHP传递来乘以1000后的时间戳:" + d);
     
    document.writeln("Javascript转换后的时间:" + jstimestamp + "<BR>");
    alert("Javascript转换后的时间:" + jstimestamp);
    //-->
    </script>

  • 相关阅读:
    关于http请求头的一些事
    关于http抓取字段的一些事
    多线程的一些事
    正则的一些事
    出现问题集及解决方案
    常见的正则
    Http常见状态码
    list&tuple简记
    函数式编程--高阶函数--sorted
    函数式编程--高阶函数--filter
  • 原文地址:https://www.cnblogs.com/webu/p/2736126.html
Copyright © 2011-2022 走看看