Date Formats

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cathy Evans
    New Member
    • Jan 2012
    • 1

    Date Formats

    I have some 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 Timer etc are just fields in Filermaker
    Code:
    "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>"
    Last edited by Dormilich; Jan 23 '12, 09:55 AM. Reason: please use [CODE] [/CODE] tags when posting code
  • adnan jan
    New Member
    • Jan 2012
    • 6

    #2
    avoid using Date() function from javascript as it works on the regional settings of the local machine which may result different output on different machines.

    Comment

    Working...