Skip to main content
Inspiring
August 18, 2015
Answered

Using "DatTimeFormat" on my cfhttp page?

  • August 18, 2015
  • 1 reply
  • 1339 views

I have the following working page but not sure how to add in a DateTimeFormat function?

Here is my current page and what I tried, but get error: Variable DATETIMEFORMAT is undefined.

Here is the online link to image: http://screencast.com/t/MKYrH1Lkp

This topic has been closed for replies.
Correct answer jlig

Getting closer.. but I need Date & Time (-60 days) in this format: 2015-06-01-00.00.00

I tried: <cfset theDate = #DateFormat(DateAdd('d', -60, now()),'yyyy-mm-dd')#-#TimeFormat(now(), "hh.mm.ss")#>

cfdump gives me: 24168

If I try: <cfset theDate = #DateFormat(DateAdd('d', -60, now()),'yyyy-mm-dd')#>

cfdump gives me:2011-06-19 (just need the time added..)


Ok, I have the working Time & Date finally!

<cfset theDate = #DateFormat(DateAdd('d', -60, now()),'yyyy-mm-dd')# & "-" & #TimeFormat(now(), "hh.mm.ss")#>

cfdump gives me the correct date & time: 2015-06-19-04.51.50

Thanks for the help.

1 reply

WolfShade
Legend
August 18, 2015

On line 10, remove the "," and replace it with a space (DateTimeFormat takes three arguments - date/time, mask, and timezone; the last two are optional.)

On line 27, surround your variable name with hashtags - #theDate#, not theDate.

HTH,

^_^

jligAuthor
Inspiring
August 18, 2015

Thanks for the help.. but still getting:

Here is my page:

Legend
August 18, 2015

What version of CF are you using?  #DateTimeFormat()# was only added in CF10.