Username Password
Bookmark and Share

DateParse - A parsing and reformatting date/time

Current version: (2005-12-22)


This macro allows to parse a date/time string and to reformat it in a custom format.

I create this macro because I needed of showing the publication date of RSS article which are in format like this

11 Dec 2005 14:44:24 GMT

but  I needed of formatting it in dd/mm/aaaa hh:mm format. I solved problem with this macro

^DateParse("%d %b %Y %T %Z","%d/%m/%y %R",<tmpl_var pubDate>");


As you see, you could use three parameters for this macro

  1. the parser string, used to parse correctly the date/time string
  2. the output format
  3. the date/time string to reformat

All these parameters are optionals and default values are

  1. %s (the date/time string is in epoch time format)
  2. user profile date/time preference
  3. current time in epoch time

So using it as ^DateParse(); return current time in your profile format.

The syntax of the format and parser strings can be found here.

This macro has been tested in 6.7.8 but should be worked also in 6.8.x.

You can see an working example here.

How to install.

To install it copy into lib/WebGUI/Macro. Then open WebGUI.conf and append

    DateParse=> DateParse

at the end of the macro section. If, as an example, last line is

    u => u_companyUrl

replace this with

    u => u_companyUrl, \
    DateParse => DateParse


System RequirementsPlease be advised: this contribution was tested with something older than WebGUI 7.5. When this contribution was uploaded there was no field for the author to fill out regarding it's requirements.
4chrisjscott: "
FYI, it appears that this DateParse macro does not work with WebGUI v7 - attempts to use it result in the following error in /var/log/webgui.log:

Undefined subroutine &WebGUI::Macro::DateParse::process called at /data/WebGUI/lib/WebGUI/ line 145.

LinksNo Support Offered
Statistics Downloads: 751
Views: 5512
Rating: 4
Updated: 12/22/2005
Keywords macros
NavigationBack to the Bazaar
© 2022 Plain Black Corporation | All Rights Reserved