Convert GMT time to local time

前端 未结 1 1076
面向向阳花
面向向阳花 2021-02-05 23:52

Am getting a GMT time from my server in this format

Fri, 18 Oct 2013 11:38:23 GMT

My requirement is to convert this time to local time using J

相关标签:
1条回答
  • 2021-02-06 00:14

    This worked for me:

    <script>
    var strDateTime = "Fri, 18 Oct 2013 11:38:23 GMT";
    var myDate = new Date(strDateTime);
    alert(myDate.toLocaleString());
    </script>
    

    Please take a look at http://www.w3schools.com/jsref/jsref_obj_date.asp for all further date time manipulations, from the date object myDate.

    0 讨论(0)
提交回复
热议问题