如何将日期从 PHP 日期变量传递给 javascript 日期变量
问题描述:
您好,我需要从 php 1328569380 获取此日期值并将其转换为 javascript 日期.顺便问一下,这个日期1328569380"类型的表格怎么称呼?
Hello i need to get this date value from php 1328569380 and convert it to javascript date. By the way how is this date "1328569380" type of form called ?
答
您所指的数字日期时间称为时间戳.如果我没记错的话,它是自 1970 年 1 月 1 日以来经过的秒数.
The numeric date time your are referring to is called a timestamp. It is the number of seconds elapsed since january 1st of 1970 if i'm not wrong.
要将日期发送到 javascript,只需使用时间戳 x 1000 打印出来,因为它也接受毫秒初始化格式:
To send a date to javascript, just print it out using the timestamp x 1000 since it also accepts millisecond initialization format:
mydate = new Date(<?php echo $mytimestamp*1000; ?>);
祝你好运