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>

  • 相关阅读:
    Visual Studio 2008 每日提示(十一)
    Visual Studio 2008 每日提示(十二)
    13 个应该记住的最不寻常的搜索引擎
    Web1.0及WEB2.0的比较
    Comparing Properties to Methods
    1
    Struct Constructor Restrictions
    简单的动态下拉菜单
    权限设计(转)
    conceptpolymorphism
  • 原文地址:https://www.cnblogs.com/webu/p/2736126.html
Copyright © 2011-2022 走看看