Highlighted

Using "DatTimeFormat" on my cfhttp page?

Contributor ,
Aug 18, 2015

Copy link to clipboard

Copied

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.

2015-08-18_1227.png

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

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.

Views

516

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Using "DatTimeFormat" on my cfhttp page?

Contributor ,
Aug 18, 2015

Copy link to clipboard

Copied

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.

2015-08-18_1227.png

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

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.

Views

517

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 18, 2015 0
LEGEND ,
Aug 18, 2015

Copy link to clipboard

Copied

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,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2015 0
Contributor ,
Aug 18, 2015

Copy link to clipboard

Copied

Thanks for the help.. but still getting:
Capture.JPG

Here is my page:

2015-08-18_1423.png

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2015 0
Engaged ,
Aug 18, 2015

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2015 0
Contributor ,
Aug 18, 2015

Copy link to clipboard

Copied

Ah.. I'm using CF9.. any alternative for me?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2015 0
Engaged ,
Aug 18, 2015

Copy link to clipboard

Copied

You can just use two separate functions: dateFormat(now(), "yyyy-mm-dd") and timeFormat(now(),"hh:mm:ss")

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2015 1
Contributor ,
Aug 18, 2015

Copy link to clipboard

Copied

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..)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2015 0
Contributor ,
Aug 18, 2015

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 18, 2015 0
LEGEND ,
Aug 20, 2015

Copy link to clipboard

Copied

Unless you are displaying variable results within a string or directly on a page (ie, you're just setting the value), you don't need the hash marks around CF variables.

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

I've not researched it, but I've heard that using hashtags around variables when setting values will slow it down.  IDK.  But they do tend to clutter code, so unless necessary, I don't use them.

Glad you got it fixed. 

HTH,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 20, 2015 1