mardi 31 mars 2015

Remove time zones from a string or format HTTP TIME STRING in coldfusion

I am formatting a normal string containing 11:00 PM or 23:00:00 using timeFormat() like this:



<cfset local.timeString = "11:00 PM">
<cfdump var="#local.timeString#">
<cfset local.newTimeString = timeFormat(local.timeString, "HH:mm:ss")>
<cfdump var="#local.newTimeString#">


Output:



11:00 PM 23:00:00



But in one case I came across a time string which also contains a time zone like this: 11:00 PM EDT, so when I was trying to format this string using timeFormat then I was getting error which is correct.



11:00 PM EDT is an invalid date or time string



This type of string can be generated using GetHttpTimeString.


Do I need to use something like this? It is not a correct way. Just thought this as found no other solution.



<cfset local.newTimeString = left(local.timeString
, len(local.timeString) - len(listLast(local.timeString," "))
)>


Is there any other function to format a string like this.


Please help. Thanks in advance.


Aucun commentaire:

Enregistrer un commentaire