I have got around 10 <div>'s and in every <div> there is a different datetime. I want to call a java-script function when the clients local time matches the time in that <div>'s.
//sample scenario
<div id="a" class ="help">2/3/2013 6:39:14 PM</div>
<div id="b" class ="help">2/3/2013 2:39:14 PM</div>
<div id="c" class ="help">2/4/2013 6:39:14 PM</div>
<div id="d" class ="help">12/29/2013 10:39:14 AM</div>
if the current date-time of the client machine matches the date-time in the <div> ; call a function say callMe()
for now I have got only - some php code :
// this is the div where the time is inserted.
<div id='<?php echo $needAnswer[$i]; ?>' class='help'></div>
// The div id and the unix time is taken from the database.
echo "<script type='text/javascript'>putTime(".$questionData['expiry'].",".$needAnswer[$i].")</script>";
And the javascript :
// this function converts the stored unix time to local time and inserts in the html (x is the unix time , y is the div id)
function putTime(x,y) {
var theDate = new Date(x*1000); // convert time value to milliseconds
var dateString = theDate.toLocaleString();
document.getElementById(y).innerHTML = dateString;
}
This all I have.
Please help me solve this step by step as I am not too good in javascript.