Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion: How to parse dd/mm/yyyy formated date?

I found the ParseDateTime function but it only parses a date/time string according to the English (U.S.) locale conventions.

How to parse the date which is in dd/mm/yyyy format?

Try out this:

<cfset TestdateFrom = ParseDateTime("10/9/2010") />
<cfloop index="i" from="1" to="30" step="1">
    <cfset TestdateFrom = DateAdd( "d", 1, TestdateFrom ) />
    #TestdateFrom#<br/>
</cfloop>

In CF9 there is a LSParseDateTime function.

I don't know whether this will help me or not.

At last should I use java library for this issue?

like image 429
Vikas Avatar asked Dec 03 '22 04:12

Vikas


1 Answers

Looks like this is working:

<cfset formatter = createObject("java","java.text.SimpleDateFormat")>
<cfset formatter.init("dd/MM/yyyy")>
<cfset newDate = formatter.parse("10/09/2010")>
#newDate#

Any other suggestions?

like image 193
Vikas Avatar answered Jan 31 '23 16:01

Vikas