javascript - Different line of text each hour -
i'm trying make site displays different line of text depending on hour (gmt). have tried using javascript, i'm beginner! i've managed piece following bit of code can't seem work. appreciated!
function gettime(zone, success) { var url = 'http://json-time.appspot.com/time.json?tz=' + zone, ud = 'json' + (+new date()); window[ud]= function(o){ success && success(new date(o.datetime)); }; document.getelementsbytagname('head')[0].appendchild((function(){ var s = document.createelement('script'); s.type = 'text/javascript'; s.src = url + '&callback=' + ud; return s; })()); } gettime('gmt', function(time){ if (time>10 && time<11) { document.write("<b>paris</b>"); } ; });
javascript has date class.
var hour = new date().gethours(); if(...) { // }
this code extract
if (hour>10 && hour<11)
can't working hours, because time can't > 10 , < 11 @ same time (hour int).
Comments
Post a Comment