Hi,
I am using the following script to display local time for 5 different countries.
However no matter what i do it always displays in US format. I have the testing server and my local PC set to GB settings I have also added the following session LCID to the page
can anyone help me sort this out please
Regards
Paul
I am using the following script to display local time for 5 different countries.
Code:
<script type="text/javascript">
/***********************************************
* Local Time script- © Dynamic Drive ([URL unfurl="true"]http://www.dynamicdrive.com)[/URL]
* This notice MUST stay intact for legal use
* Visit [URL unfurl="true"]http://www.dynamicdrive.com/[/URL] for this script and 100s more.
***********************************************/
var weekdaystxt=["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
var months=["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
function showLocalTime(container, servermode, offsetMinutes, displayversion){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.displayversion=displayversion
var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>'
this.localtime=this.serverdate=new Date(servertimestring)
this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time
this.updateTime()
this.updateContainer()
}
showLocalTime.prototype.updateTime=function(){
var thisobj=this
this.localtime.setSeconds(this.localtime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}
showLocalTime.prototype.updateContainer=function(){
var thisobj=this
if (this.displayversion=="long")
this.container.innerHTML=this.localtime.toLocaleString()
else{
var hour=this.localtime.getHours()
var minutes=this.localtime.getMinutes()
var seconds=this.localtime.getSeconds()
var ampm=(hour>=12)? "PM" : "AM"
var currentdate=this.localtime.getDate()
var year=this.localtime.getFullYear()
var dayofweek=weekdaystxt[this.localtime.getDay()]
var date=months[this.localtime.getMonth()]
//this.container.innerHTML=" "+dayofweek+" "+formatField(hour, 1)+":"+formatField(minutes)+""+ampm+" "+dayofweek+" "
this.container.innerHTML=""+dayofweek+", "+currentdate+" "+date+" "+year+" "+formatField(hour, 1)+":"+formatField(minutes)+" "+ampm+" "
}
setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
}
function formatField(num, isHour){
if (typeof isHour!="undefined"){ //if this is the hour field
var hour=(num>12)? num-12 : num
return (hour==0)? 12 : hour
}
return (num<=9)? "0"+num : num//if this is minute or sec field
}
</script>
However no matter what i do it always displays in US format. I have the testing server and my local PC set to GB settings I have also added the following session LCID to the page
Code:
<% '***Start Session ID Code and Sets the server locale
session.LCID = 2057
'***End Session ID Code
%>
can anyone help me sort this out please
Regards
Paul