Rumah >pembangunan bahagian belakang >tutorial php > PHP的时间戳让JS显示,显示不正确!该怎么处理
PHP的时间戳让JS显示,显示不正确!
<!-- 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>
[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>