Format PHP and Javascript clock -
i took code php javascript code, live clock , , put on website. code here:
<?php function d1() { $time1 = time(); $date1 = date("h:i:sa",$time1); echo $date1; } ?> <script> var = new date(<?php echo time() * 1000 ?>); function startinterval(){ setinterval('updatetime();', 1000); } startinterval();//start right away function updatetime(){ var nowms = now.gettime(); nowms += 1000; now.settime(nowms); var clock = document.getelementbyid('qwe'); if(clock){ clock.innerhtml = now.totimestring();//adjust suit } } </script> <div id="qwe"></div>
however, time format shows this:
21:41:44 gmt-0400 (eastern standard time)
i want show
9:41:44 pm
i assume line
clock.innerhtml = now.totimestring();//adjust suit
is 1 need change, can't find formats show simply. need write myself show in custom format?
i want suggest try use developer tools in chrome examine properties , functions available object.
try this, f12 developer tool , in there type
var date_new = new date()
then type date_new. after pressing dot, you'll see potential functions available you
of course, read on official documentation know this, in case don't have internet connection or in hurry. can around @ functions of date object.
have fun coding!
Comments
Post a Comment