如何将日期从 PHP 日期变量传递给 javascript 日期变量 [英] How to pass date from Php date variable to javascript date variable

查看:33
本文介绍了如何将日期从 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; ?>);

祝你好运

这篇关于如何将日期从 PHP 日期变量传递给 javascript 日期变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆