Javascript to convert UTC to local time

后端 未结 8 1038
暖寄归人
暖寄归人 2020-11-27 06:23

Okay, say JSON parse string UTC date as below:

2012-11-29 17:00:34 UTC

Now if I want to convert this UTC date to my local time, how can I d

8条回答
  •  渐次进展
    2020-11-27 07:01

    /*
     * convert server time to local time
     *  simbu
    */
    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;
    }
    

提交回复
热议问题