我從服務器獲取字符串,我需要隱藏獲取字符串中的新日期對象..爲此,我試過這個功能,但沒有用,任何人都可以幫助我將字符串轉換爲日期對象?如何將文本字符串更改爲日期對象?
我的代碼是:
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
'日期'應該如何神奇地知道你通過紐約當地時間? –