Skip to main content
Known Participant
October 7, 2007
Question

datetime converter

  • October 7, 2007
  • 2 replies
  • 1051 views
Hi i have a datetime converter to a users local datetime, but i am getting this error

"{ts '2007-10-07 04:20:21'}" is an invalid date or time string.

i am not sure why this is?

<cfset startday = #NOW()#>
<cfscript>
tz=createObject("component","timeZone");
setLocale("English (Australian)");
smsDate=lsParseDateTime(startday);
hours=listFirst(SMS_Time,":")+listGetAt(SMS_Time,2,":")/60+listLast(SMS_Time,":")/360;
smsDate=dateAdd("h",hours,smsDate);
serverDate=tz.castToServer(smsDate,Australia/Sydney);
</cfscript>
This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
October 7, 2007
Coldfusion expects the string argument of LSParseDatetime to be "in a format that is readable in the current locale.". Apparently, the string "{ts '2007-10-07 04:20:21'}" is not. Note that parseDateTime(now()) would probably work.

Two possible solutions are
<cfset startday = now()>
<!--- <cfset dt = REreplace(startday, "[ts'{}]","","all")> --->
<cfset dt = LSDateformat(startday,"yyyy-mm-dd") & " " & LSTimeFormat(startday,"hh:mm:ss")>
<cfoutput>#LSparsedatetime('#dt#')#</cfoutput>



Known Participant
October 7, 2007
ok thanks i have sorted that now, but the problem is the datetime conversion is incorrect

if you look at
http://65.98.61.146/$sitepreview/thesmsengine.com/TestFiles/timetest.cfm

you will see the time in Sydney Australia is wrong

any ideas
Inspiring
October 7, 2007
KeithLaw999 wrote:
> Hi i have a datetime field im sql server, i need to insert a datetime but i am
> getting this error
>
> "{ts '2007-10-07 04:20:21'}" is an invalid date or time string.
>
> how do i need to convert this for sql server?

you shouldn't, that's a valid cf datetime. what db driver are you using? can you
post the code?