Error in createdatetime
Copy link to clipboard
Copied
<cfset schedindtl.pressdate = 20090308>
<cfset pressstart = #createdatetime(mid(schedindtl.pressdate,1,4),mid(schedindtl.pressdate,5,2),mid(schedindtl.pressdate,7,2),int(schedindtl.presstime/100),int(right(tostring(schedindtl.presstime),2)),0)#>
pressstart = #pressstart#
Looks like daylight savings time problem. Looking for help in fixing.
Copy link to clipboard
Copied
It'd help if you posted what error you're getting.
That code works fine for me.
You don't need the pound-signs on the third line, btw. This will not
impact your situation at all, but it makes your code look tidier.
--
Adam
Copy link to clipboard
Copied
Date value passed to date function CreateDateTime is unspecified or invalid.
Specify a valid date in CreateDateTime function.
Copy link to clipboard
Copied
quote:
Originally posted by: djl2445
Here is the error.
Date value passed to date function CreateDateTime is unspecified or invalid.
Specify a valid date in CreateDateTime function.
You are passing it a string. Not sure why it work for Adam and not for you.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
For example:
CreateDateTime(2009, 3, 8, 2, 45, 0)
Will through the following error:
Date value passed to date function CreateDateTime is unspecified or invalid.
Specify a valid date in CreateDateTime function.
Copy link to clipboard
Copied
> and time of 2am.
>
> For example:
>
> CreateDateTime(2009, 3, 8, 2, 45, 0)
In US TZs, there is no 2:45am on March 8. Daylight savings kicks in @ 2am,
and the time automagically becomes 3am. "2009-03-08 02:45:00" does not
exist as a time in the US.
--
Adam
Copy link to clipboard
Copied
I can only guess that this is the rationale for it being an invalid date/time.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Wait a minute. Wouldn't that time be perfectly valid for the portions of the US that do not observe daylight savings time? Arizona and Hawaii do not observe DST. Indiana did not observe DST until 2005.
CrystalTech, a popular CF webhost, is situated in Arizona, I believe. It would seem to me that the server time would be perfectly valid on those boxes, wouldn't it? Is it simply a matter of not applying the DST patch to those machines?
Copy link to clipboard
Copied
> US that do not observe daylight savings time? Arizona and Hawaii do not observe
> DST. Indiana did not observe DST until 2005.
Yep, and it'll work fine in those TZs. It's only when the server is
configured to be in one of the affected TZs that it's a problem. I'm on
GMT here and the code works fine, because our DLS boundary is different.
29/3/2009 01:30 bombs for me.
> CrystalTech, a popular CF webhost, is situated in Arizona, I believe. It would
> seem to me that the server time would be perfectly valid on those boxes,
> wouldn't it? Is it simply a matter of not applying the DST patch to those
> machines?
If one is serving content across TZs, one should really have the server set
to UTC and have your code offset the time as per requirements. Paul
Hastings might be watching out, and this would be his cue to jump in and
explain all that. He's the expert.
--
Adam
Copy link to clipboard
Copied
>> US that do not observe daylight savings time? Arizona and Hawaii do not observe
>> DST. Indiana did not observe DST until 2005.
A can't *believe* I didn't have more concerted swipe at you for only
considering USA when made your observation above.
A wasted opportunity!
;-)
--
Adam
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I am having a problem here:
<cfscript>
writeoutput(createdatetime(2022,03,13,2,0,0));
</cfscript>
Got this error:
Date value passed to date function createDateTime is unspecified or invalid.
Is this related w/ the JVM that I am using? Please help. Thanks.
Copy link to clipboard
Copied
Just reported the bug:
https://tracker.adobe.com/#/view/CF-4212875
Copy link to clipboard
Copied
Does the following help as a workaround?
- add the timezone flag to java.args in the jvm.config file. For example, I have added:
-Duser.timezone=Europe/London
Copy link to clipboard
Copied
I can't change this because the app is running in US/Los Angeles time zone. For our European server everything is working great.
Thanks.
Copy link to clipboard
Copied
Oh, what I mean is that you should add your own time-zone to jvm.config. That is,
-Duser.timezone=America/Los_Angeles
Copy link to clipboard
Copied
Does that help?
Copy link to clipboard
Copied
Nope. Thanks.
Copy link to clipboard
Copied
Did you restart ColdFusion after adding the (JVM time-zone) flag? Restarting is crucial.
Copy link to clipboard
Copied
Just to be sure, does the following work?
<cfscript>
writeoutput(createdatetime(2022,3,13,2,0,0));
</cfscript>
The documentation on CreateDateTime says its arguments should be integers. So, when you use 03 in place of 3, you are in questionable territory. ColdFusion cannot then offer you any guarantees.


-
- 1
- 2