Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


DateFormat / Timestamp

Posted on 2007-07-26
Medium Priority
Last Modified: 2013-12-16
I know this should be easy but I can't seem to find out the following. If I'm using a JavaScript calendar and the formatting is yyyy/mm/dd when a date is selected. How can input the the yyyy/mm/dd formated text to a timestamp so I can format the date however I need to in the future.  For example : {ts '2007-07-26'} format.


Question by:brihol44
  • 2
LVL 14

Expert Comment

by:Scott Bennett
ID: 19578619
just use parsedatetime:

LVL 39

Accepted Solution

gdemaria earned 2000 total points
ID: 19580283
Since the format of your date is not coldfusion's standard format, it may not correctly understand the date.  For example is 2007/12/1  Dec 1st or Jan 12th?

You can test this to see if CF gets it right, or you can parse it out manually and create the date like this...

<cfset theDate = createDate( listFirst(theString,"/"), listGetAt(theString,2,"/"), listLast(theString,"/") )>

 Now the variable theDate will contain a valid date and you can format it using
  dateFormat(theDate, "mm/dd/yyyy")
or insert it into the database using..

If there is a chance this parsing will not contain a valid date, enclose the statement in CFTRY and CFCATCH statements to ensure your createDate() does not throw an error.

LVL 14

Expert Comment

by:Scott Bennett
ID: 19582416
That is not neccessary. yyyy/mm/dd is indeed how coldfusion expects it for the parsedateeimt function. You would only have to do the createDate method if you were using yyyy/dd/mm and then it would be :
<cfset theDate = createDate( listFirst(theString,"/"), listLast(theString,"/"), listGetAt(theString,2,"/") )>

try it out:
<cfset mydate="2007/12/1">

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question