Home >Backend Development >PHP Tutorial > PHP的时间戳让JS显示,显示不正确!该怎么处理

PHP的时间戳让JS显示,显示不正确!该怎么处理

WBOY
WBOYOriginal
2016-06-13 13:37:00784browse

PHP的时间戳让JS显示,显示不正确!

HTML code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->



<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>时间</title>



<script type="text/javascript">
var time = new Date(<?php echo(time());?> * 1000);
alert(time.getFullYear() + "-" + time.getMonth() + "-" + time.getDay() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds());
</script>





------解决方案--------------------
HTML code
[code=PHP]


<meta http-equiv="Content-Type" content="text/html, charset=utf-8">
<title>时间</title>



<?php echo date('Y-m-d H:i:s');?><br>
<script type="text/javascript">
var time = new Date(<?php echo(time());?>*1000);
document.write(time.getFullYear() + "-" + (time.getMonth()+1) + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds());
</script>

 <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn