将服务器时间转换为本地时间javascript

时间:2014-10-14 04:54:00

标签: javascript date time timing

new Date(entry["startdatetime"]).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3")

我如何将服务器时间转换为当地时间现在我的时间是18:30相当于下午6:30。

我的new Date(entry["startdatetime"])值为

enter image description here

服务器时间如下:

enter image description here

请有人帮忙

2 个答案:

答案 0 :(得分:0)

  1. <% new SimpleDateFormat("dd-MMM-yyyy").format(new Date()) %>这可用于打印14-oct-2014

  2. 如果找到,请使用my date: &nbsp;<%= new java.util.Date() %> = out put my date:  Tue Oct 14 10:52:39 IST 2014。使用这种语法我认为这将解决您的问题。

答案 1 :(得分:0)

function convertTime(serverdate) {
    var date = new Date(serverdate);
    // convert to utc time
    var toutc = date.toUTCString();
    //convert to local time
    var locdat = new Date(toutc + " UTC");
    return locdat;
}