Hi all
Thank you for your replies. Unfortanetly i can’t make it work.
This is the sourcecode - executed on CF9
<cfoutput>#GetLocale()#</cfoutput><br>
<cfoutput><cfset SetLocale('de_CH')></cfoutput>
<cfoutput>#GetLocale()#</cfoutput><br>
<cfset past_date = "#LSDateFormat("11.10.2014", "dd. mmm yyyy")# #LSTimeFormat("01:00")#">
<cfset current_date = "#LSDateFormat(Now(), "dd. mmm yyyy")# #LSTimeFormat(Now())#">
past_date: <cfoutput>#past_date#</cfoutput><br>
current_date: <cfoutput>#current_date#</cfoutput><br>
<cfset diff_months = #DateDiff("m", "#past_date#", "#current_date#")# >
diff_months: <cfoutput>#diff_months#</cfoutput>
This throws this output:
German (Swiss)
German (Swiss)
past_date: 11. Okt 2014 01:00
current_date: 07. Nov 2022 19:42
diff_months: 96
This is the sourcecode - executed on Lucee (locale is in a different fomat, everything else is identical):
<cfoutput>#GetLocale()#</cfoutput><br>
<cfoutput><cfset SetLocale('swiss german')></cfoutput>
<cfoutput>#GetLocale()#</cfoutput><br>
<cfset past_date = "#LSDateFormat("11.10.2014", "dd. mmm yyyy")# #LSTimeFormat("01:00")#">
<cfset current_date = "#LSDateFormat(Now(), "dd. mmm yyyy")# #LSTimeFormat(Now())#">
past_date: <cfoutput>#past_date#</cfoutput><br>
current_date: <cfoutput>#current_date#</cfoutput><br>
<cfset diff_months = #DateDiff("m", "#past_date#", "#current_date#")# >
diff_months: <cfoutput>#diff_months#</cfoutput>
But this throws this output:
english (us)
Swiss German
can’t cast [11. Okt 2014 01:00] to date value
17: <cfset diff_months = #DateDiff(“m”, “#past_date#”, “#current_date#”)# >
If i try to use the suggenstion from above (lsparsedatetime) by using this sourcecode executed on Lucee:
<cfoutput>#GetLocale()#</cfoutput><br>
<cfoutput><cfset SetLocale('swiss german')></cfoutput>
<cfoutput>#GetLocale()#</cfoutput><br>
<cfset past_date = lsparseDateTime(date="11.10.2014 01:00", format="dd. MMM yyyy hh:mm")>
<cfset current_date = lsparseDateTime(date="Now()", format="dd. MMM yyyy hh:mm")>
past_date: <cfoutput>#past_date#</cfoutput><br>
current_date: <cfoutput>#current_date#</cfoutput><br>
<cfset diff_months = #DateDiff("m", "#past_date#", "#current_date#")#>
diff_months: <cfoutput>#diff_months#</cfoutput>
Then i get this error:
english (us)
Swiss German
Unparseable date: “11.10.2014 01:00”
<cfset past_date = lsparseDateTime(date=“11.10.2014 01:00”, format=“dd. MMM yyyy hh:mm”)>
Does somebody having an idea how to make this work or does know what i’m doing wrong?
Regards
Tom