I needed to do just that on a project a while back so I dug up 
this file for you. I haven't looked at it since I did it, so 
if you have problems or questions let me know and I'll take a 
closer look.

DM
*****************
<cfif isDefined('set')>
~<cfoutput>
~Your Time: #TimeFormat(hour,"h:mm tt")#<br>
~server Time: #TimeFormat(now(),"h:mm tt")#<br>
~
~<cfset serverhour = now()><!--- TimeFormat(now(),"H") --->
~
~<cfset hourDiff =  DateDiff("h", serverHour, hour )>
~Hour Difference: #hourDiff#<br>
~
~<cfcookie name="HourDiff" value="#hourDiff#" expires="NEVER">
~set cookie: #cookie.hourDiff# hours
</cfoutput>
<cfelse>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
~<title>Untitled</title>

<script>
function dohour(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()+1
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()

var cdate="{ts '"+year+"-"+month+"-"+daym+" "+hours+":"+minutes+":00'}";

document.form.hour.value=cdate;
document.form.submit()
}
</script>

</head>

<body onLoad="dohour()">
<form action="#" method="post" name="form">
~<input type="hidden" value="" name="hour">
~<input type="hidden" name="set" value="t">
</form>

**********************


= = = Original message = = =

Hello all,
We have clients in many different time zones, and we would like 
to find an
easy way to get the local time from the browser rather than querying 
a
time_zone table every time or setting a session variable.  Almost 
like a
reverse cfheader where we get info from the browser instead of 
sending it.
Any ideas?  Thanks.
Ryan

______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to