Paul Hastings wrote:
> Rick Root wrote:
>
>>It does when you use dateConvert('local2utc',Now())
>>
>>Doesn't it?
>
>
> http://www.sustainablegis.com/blog/cfg11n/index.cfm?mode=entry&entry=77223B6A-20ED-7DEE-2AB7FBB1F37ABD77
Curious that the entry makes NO mention of the dateConvert() function.
Of course, I understand it's meaning - that coldfusion still doesn't
know anything about timezones in datetime objects. Which is fine for my
purposes.. as long as the local SERVER time is converted to UTC time,
I've got something to work with.
>>I think what I might have to do is store the dates in UTC string format,
>
> sorting, etc. will fly out the door if you do. java epoch offset might
> be a better choice.
Actually, UTC Strings are nicely sortable because they look like this:
2006-09-08T18:20:00Z
However, Javascript actually needs IETF formats, which look like this:
Fri, 08 Sep 2006 18:20:00 Z
Which is totally unsortable. But in my case, I don't need sorting...
So I'm inserting the 27 character ietf time string into the database,
and having javascript convert it to the browser local time.
Here's my CF function:
<cfscript>
function date2ietfString(dt)
{
return dateFormat(dt,'ddd, dd mmm yyyy') & ' ' & timeformat(dt,
'HH:mm:ss') & ' Z';
}
</cfscript>
And here's my javascript getTimestamp function that does the conversion:
function getTimestamp(dt)
{
var today=new Date(Date.parse(dt));
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
if (m < 10) { m = '0' + '' + m; }
if (s < 10) { s = '0' + '' + s; }
// m=checkTime(m)
// s=checkTime(s)
var result=h+":"+m+":"+s
return result;
}
Now, the dates are stored in the database in UTC time and returned to
the browser, which properly displays the correct time based on the
browser's timezone.
Hooray!
Rick
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four
times a year.
http://www.fusionauthority.com/quarterly
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:252600
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4