java - Javascript : Windows 7 taskbar time (Almost Done) But it is still in 24 hour format -


i have created windows 7 time, done still in 24 hour format.

javascript :-

<script> function date_time(id){     date = new date;     year = date.getfullyear();     month = date.getmonth();     months = new array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');     d = date.getdate();     day = date.getday();     days = new array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');     h = date.gethours();     if(h<10)     {             h = ""+h;     }     m = date.getminutes();     if(m<10)     {             m = "0"+m;     } = date.gethours() < 12 ? 'am' : 'pm';     result = ''+h+':'+m+' '+a+'<br/>'+months[month]+'/'+d+'/'+year;     document.getelementbyid(id).innerhtml = result;     settimeout('date_time("'+id+'");','1');     return true; } </script> 

html :-

                <span class="right" id="date_time"></span>             <script type="text/javascript">window.onload = date_time('date_time');</script> 

i want change format of hour 12 not 24

you not converting hours 12 hours format.

add line

h = h % 12 

after line set 'a'.

and remove

if(h<10) {      h = ""+h; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -