CFLib.org – Common Function Library Project

ISODateToTS(str)

Last updated September 21, 2004
Download UDF

author

James Edmunds                                     James Edmunds

Version: 1 | Requires: ColdFusion 5 | Library: DateLib

 
Rated 0 time(s). Average Rating: 0

Description:
Takes a text string of an ISO date and converts it to a datetime object. This is useful when parsing an RDF or RSS feed that uses Dublin Core or otherwise uses ISO formatted dates. Strips the date time down to the hour and minute, omitting seconds (as some feeds do not use seconds). Please note that the tiem zone is ignored.

Return Values:
Returns a date.

Example:

<CFSET theISODateString = "2004-04-06T18:32:03Z">
<CFSET theDateTime = ISODateToTS(theISODateString)>
<CFOUTPUT>
The ISO date string in text form: #theISODateString#<br>
The date and time: #dateformat(thedatetime, "m.dd.yyyy.")# #timeformat(thedatetime, "hh:mm tt")#<br>
</CFOUTPUT>

Parameters:

Name Description Required
str ISO datetime string to parse. Yes

Full UDF Source:

<cfscript>
/**
* Converts text string of ISO Date to datetime object; useful for parsing RSS and RDF.
*
* @param str      ISO datetime string to parse. (Required)
* @return Returns a date.
* @author James Edmunds (jamesedmunds@jamesedmunds.com)
* @version 1, September 21, 2004
*/

function ISODateToTS(str) {
    return ParseDateTime(ReplaceNoCase(left(str,16),"T"," ","ALL"));
}
</cfscript>

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
2 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson