Advanced Date Parsing with ColdFusion

Discussion in 'Programming' started by digga121, Aug 26, 2008.

  1. #1
    Advanced Date Parsing with ColdFusion

    This is helpfull if you scrape an RSS Feed, and need to format the date, to your own likings. *hint* For instance , you want to take the RSS Feed date, get the #month#, #date#, then create a page, based on that date ..

    /#month#/#date#/#year#/#rsstitle#.cfm

    Anyway, normal parsedate() would work, however, this puts in concideration time zones ! ...

    <cfset date = GetHttpTimeString()>
    <cfset formatter = CreateObject("java", "java.text.SimpleDateFormat")>
    <cfset formatter.init("EEE, dd MMM yyyy HH:mm:ss Z")>
    <cfset parsePosition = CreateObject("java", "java.text.ParsePosition")>
    <cfset parsePosition.init(0)>
    <cfset newDate = formatter.parse(date, parsePosition)>
    <cfoutput>
    GetHttpTimeString = #date# <br />
    SimpleDateFormat = #newDate# <br />
    ParseDateTime = #ParseDateTime(date)#
    </cfoutput>
    Code (markup):
    Original Post: http://www.petefreitag.com/item/569.cfm
     
    digga121, Aug 26, 2008 IP