Discussion:
PST to UTC
(too old to reply)
catchme_dileep
2009-03-16 05:05:09 UTC
Permalink
Hi All,

How can i convert to date in PST to its equivalent UTC?

Please help
Azadi
2009-03-16 08:05:03 UTC
Permalink
doesn't DateConvert() cf function work for you?
details are in CFML Reference - download from adobe.com if you do not
have one.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
PaulH **AdobeCommunityExpert**
2009-03-16 08:25:31 UTC
Permalink
Post by Azadi
doesn't DateConvert() cf function work for you?
details are in CFML Reference - download from adobe.com if you do not
have one.
unless the server's in PST tz no, it won't convert correctly. cf sees all
datetimes as being in the server tz so when you have datetimes on the DST
boundary, those datetimes will never exist, ie when PST becomes PDT (again
depending on the server tz).

for tz casting have a look at:

http://www.sustainablegis.com/projects/tz/testTZCFC.cfm

and maybe read some of these for some of the joys of working w/tz:

http://www.sustainablegis.com/blog/cfg11n/index.cfm?mode=cat&catid=162AEDB4-20ED-7DEE-2A6CF1B79AC2E03A
catchme_dileep
2009-03-16 08:37:43 UTC
Permalink
I am getting a date in the following format from a web service "23:19:50 Mar 15, 2008 PDT". I would like to convert this date to UTC format
PaulH **AdobeCommunityExpert**
2009-03-16 09:08:48 UTC
Permalink
Post by catchme_dileep
I am getting a date in the following format from a web service "23:19:50 Mar 15, 2008 PDT". I would like to convert this date to UTC format
well the first problem is that's not any locale's standard datetime format (well
none that i know of). if you're 100% sure that's the date format you'll *always*
get this will get parse it:

<cfscript>
df=createObject("java","java.text.SimpleDateFormat").init("H:m:s MMM d, yyyy z");
funnyDateFormat="23:19:50 Mar 15, 2008 PDT";
writeoutput("#df.parse(funnyDateFormat)#");
</cfscript>

what you'll get back is a datetime object in the cf server's timezone (tz). you
can then use dateConvert on it to get to UTC. just remember those pitfalls of tz
handling.
Azadi
2009-03-16 08:44:08 UTC
Permalink
i kinda figured since the OP is so sure the original time is in PST,
that must be the server tz...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
PaulH **AdobeCommunityExpert**
2009-03-16 08:48:03 UTC
Permalink
Post by Azadi
i kinda figured since the OP is so sure the original time is in PST,
that must be the server tz...
using a hosted cf server for an app that has to handle different tz will quickly
get you out of that mind set (or drive you nuts ;-)
Azadi
2009-03-16 09:06:03 UTC
Permalink
i know! i am almost dreading the moment i have to make a fully tz-aware
app... hope being on my own vps will be of help?

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
PaulH **AdobeCommunityExpert**
2009-03-16 09:13:58 UTC
Permalink
Post by Azadi
i know! i am almost dreading the moment i have to make a fully tz-aware
app... hope being on my own vps will be of help?
yeah the cheapest solution is UTC tz on the server & cast to user tz. next best
is dumping datetimes & use epoch offsets. best of all is that cf gets a set tz
method :-)

Loading...