javascript - How to format a js date? -
i writing code seems don't result want. real time clock.
<p id="time"></p> <script type="text/javascript"> function updatetime(){ $('#time').html(new date()); } $(function(){ setinterval(updatetime, 1000); }); </script>
this result:
tue aug 15 2017 13:34:09 gmt+0800 (china standard time)
how can format date , time this: "tue august 15, 2017 1:30pm"
using moment.js easy achieve
var dt = moment([2015, 1, 14, 15, 25, 50, 125]); dt.format("dddd, mmmm yyyy, h:mm:ss a"); //prints "sunday, february 14th 2015, 3:25:50 pm"
Comments
Post a Comment