AnsweredAssumed Answered

Javascript dates

Question asked by Gingernut on Jan 21, 2012
Latest reply on Jan 22, 2012 by Gingernut

Alarm Clock in webviewer using Fields for alert times

 

I have been trying to use Inspired Business Suite Javascript in a Filemaker file that basically sets a timer and or alarm It works perfectly in the file I was given to dowload USA based but when I import it into my local UK file it does not work The Timer is prob easiest example to show

 

When I add 1 minute in UK file it shows 13145 hours plus 1 minute

 

How do I convert the date formats please

 

I am not at all familiar with Java (but can work out what is being done) my timestamps etc all look ok in the local file IE shows full date and time as 21st January 2012 15:23

Thanks in anticipation

 

Cathy

"data:text/html,<html>

<head>

<script type='text/javascript'>

 

/*Setting JavaScript Variables to value of FileMaker fields*/

var targetTimeTxt = '" & Timer::Timestamp_End & "';

var status = '" & Timer::Status & "';

var labelTxt = '" & Timer::Label & "';

/*End FileMaker Fields*/

 

var currentTime = new Date();

var targetTime = new Date(targetTimeTxt);

var remaining = Math.floor((targetTime - currentTime)/1000);

 

function setClock()

{

var currentTime = new Date();

var clock = document.getElementById('clock');

var labelobj = document.getElementById('label1');

var secondsRemaining=0;

 

if(labelTxt=='')

{

labelobj.innerHTML='Timer';

}

else

{

labelobj.innerHTML=labelTxt;

}

 

if (targetTime>currentTime)

{

secondsRemaining=Math.floor((targetTime - currentTime)/1000);

}

 

var hours = Math.floor( secondsRemaining / 3600 );

var minutes = Math.floor((secondsRemaining%3600) / 60 );

if(minutes<10)minutes='0' + minutes;

var seconds = secondsRemaining%60;

if(seconds<10)seconds='0'+seconds;

 

clock.innerHTML=hours + ':' + minutes + ':' + seconds;

 

if(targetTimeTxt=='' || status=='Acknowledged' || ( secondsRemaining==0 && Math.floor(currentTime/1000)%2==0 ) )

{

document.body.style.backgroundColor='#FFFFFF';

if ( targetTimeTxt=='' || status=='Acknowledged' )

{

clock.innerHTML='--:--:--';

}

}

else if(secondsRemaining==0)

{

document.body.style.backgroundColor='#FFFF00';

document.getElementById('sound1').Play();

}

 

setTimeout('setClock();',1000);

}

 

</script>

</head>

<body style='margin:4px;padding:0;font-size:14px;font-weight:bold;font-family: Arial, Helvetica, sans-serif;text-align:center;background-color:#FFFFFF;' onload='setClock();'>

<div id='label1' style='font-size:10px;font-weight:bold;'>

</div>

<div id='clock'>

</div>

<embed src='file:///System/Library/Sounds/Glass.aiff' autostart='false' id='sound1'

enablejavascript='true' width='0' height='0'>

</body></html>"

Outcomes