我从服务器获取字符串,我需要隐藏获取字符串中的新日期对象..为此,我试过这个功能,但没有用,任何人都可以帮助我将字符串转换为日期对象?如何将文本字符串更改为日期对象?
我的代码是:
var nationZone = {
getNewYorkLocalTime : 'getTime.php?lat=40.71417&lan=74.00639',
getLondonLocalTime : 'getTime.php?lat=51.5&lan=0.1166667',
getChennaiLocalTime : 'getTime.php?lat=13.0833333&lan=80.2833333',
getBangaloreLocalTime:'getTime.php?lat=12.9833333&lan=77.5833333'
}
$.each(nationZone , function(key, value){
$.get(value, function(response){
var newdate = $(response).find('localtime').text();
if(key == "getNewYorkLocalTime"){
var newyourktime = new Date(newdate);
newyourktime.getTime()
}
});
});
但是,在newyourktime只显示本地时间..任何帮助吗?以及我从服务器得到的回应是:2011年11月17日18时09分47秒 - 像这样。
你能提供从服务器的响应? – antyrat
来自服务器的回复:2011年11月17日18时09分47秒 – 3gwebtrain
'日期'应该如何神奇地知道你通过纽约当地时间? –