1
我怎么能转换日期时间从JS返回此功能JS日期时间到PHP转换
var now = new Date();
output: Sun Feb 24 2013 01:26:47 GMT+0800 (MYT)
到PHP可读格式如date(YmdHis)
?
我怎么能转换日期时间从JS返回此功能JS日期时间到PHP转换
var now = new Date();
output: Sun Feb 24 2013 01:26:47 GMT+0800 (MYT)
到PHP可读格式如date(YmdHis)
?
返回从您的JavaScript函数的UNIX时间戳:
Math.round(new Date().getTime()/1000) //returns number of seconds since epoch
然后简单地使用在PHP的日期功能:
$yourJsTime = $_GET['jsTime']; //depends on how you pass your js timestamp
date_default_timezone_set('UTC');
echo date('YmdHis', $yourJsTime);
http://www.w3schools.com/jsref/jsref_obj_date.asp – 2013-02-23 17:31:08
@MarshallHouse:http://w3fools.com – 2013-02-23 17:48:02
@MarcB这个网站看起来真的是过度反应。如果他们有不好的信息,这可能是很好的细节,我会克服它。不像你可以更好地相信其他博客。 w3schools非常方便,除了缺乏详细说明(大部分是PHP),我还没有遇到过问题。我现在总是使用php.net。但对于JS ..还有什么地方? – 2013-02-23 17:57:09