CFLib.org – Common Function Library Project

GMTDateFormat(aDate, offset)

Last updated March 21, 2002

author

Mark Andrachek

Version: 1 | Requires: CF5 | Library: DateLib

Description:
This takes two arguments, adate and offset. adate should be a valid date/time object, and offset should be a valid GMT offset (formatted +0000 or -0000, for example, Eastern Standard Time is -0500). It will then output a valid GMT string. It's especially usefull to help prevent browser and proxy caching.

Return Values:
Returns a string.

Example:

<cfset oldtime = DateAdd('n',1,Now())>
<cfoutput>
#GMTDateFormat(variables.oldtime,'-0500')#
</cfoutput>

Parameters:

Name Description Required
aDate A date. Yes
offset A valid GMT offset. Yes

Full UDF Source:

/**
 * This function takes a date time object and an offset, and outputs a GMT date/time formatted string.
 * 
 * @param aDate      A date. 
 * @param offset      A valid GMT offset. 
 * @return Returns a string. 
 * @author Mark Andrachek (hallow@webmages.com) 
 * @version 1, March 21, 2002 
 */
function GMTDateFormat (adate,offset) {
     // adate must be a valid date time object.
     // the offset must be in the format -0000 or +0000.
     
     var dvalue = ""; // the final value.
     
     if (IsDate(adate)) {
          
          dvalue = DateAdd('h',Left(offset,3),DateAdd('s',Left(offset,1) & Right(offset,2),adate));
          dvalue = Left( DayOfWeekAsString( DayOfWeek( dvalue ) ), 3) & 
                  ', ' & 
                  DateFormat(dvalue,'dd mmm yyyy') &
                  ' ' &
                  TimeFormat(dvalue,'HH:mm:ss') &
                  ' GMT';
          
          return dvalue;
     }
     
     else { return; }
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson