ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Simpledate - outputs current or last modified date

August 24, 2010 2:25pm

Subscribe [8]
  • #1 / Aug 24, 2010 2:25pm

    Aaron Fowler

    113 posts

    My first (very simple) addon - Simpledate outputs the current date or the page’s last modified date using PHP formatting options.

    Simpledate has two functions:

    {mojo:simpledate:get}

    simply returns the current date.

    {mojo:simpledate:get_last_modified}

    returns the page’s last modified date.

    Format parameter using PHP formatting options:

    {mojo:simpledate:get format="Y-m-d"}

    will return something like “2010-08-01”

    If no format parameter is used, Simpledate will default to “F j Y” (e.g. August 1 2010).

    Offset parameter in seconds:

    {mojo:simpledate:get offset="172800"}

    will add 2 days (60 * 60 * 24 * 2) to the current date.  Prefix the seconds with a negative sign to subtract time, e.g., offset=”-172800”.


    Download and documentation:
    http://github.com/aaronfowler/mojo-simpledate


    -Aaron

  • #2 / Aug 24, 2010 2:38pm

    jschutt

    452 posts

    Way to go Aaron! Thanks for contributing to the community!

  • #3 / Aug 24, 2010 3:06pm

    Nice work, Aaron!

  • #4 / Aug 24, 2010 6:03pm

    Loic Sharma

    114 posts

    Ooh, this is nice! Hadn’t thought of this. Good job 😊

  • #5 / Aug 25, 2010 12:20am

    Sue Crocker

    26054 posts

    Aaron, is it possible to return the present date minus x number of days? I have a client that does a sales letter that appears to be current as of 2 days earlier. 😊

  • #6 / Aug 25, 2010 9:26am

    Loic Sharma

    114 posts

    Aaron, is it possible to return the present date minus x number of days? I have a client that does a sales letter that appears to be current as of 2 days earlier. 😊

    If you know the timestamp of that sales letter, you can input that to the the get tag like this (where 123123123 is your timestamp):

    {mojo:simpledate:get time="123123123"
  • #7 / Aug 25, 2010 11:26am

    Aaron Fowler

    113 posts

    Sue,

    Version 1.1 now has an “offset” parameter to allow you to do this.

    Both tags accept an offset parameter in seconds:

    {mojo:simpledate:get offset="172800"}

    will add 2 days (60 * 60 * 24 * 2) to the current date.  Prefix the seconds with a negative sign to subtract time, e.g., offset=”-172800”.

    Maverfax is also correct - there is an undocumented “time” parameter that accepts a Unix timestamp.

    -Aaron

  • #8 / Aug 25, 2010 1:48pm

    Sue Crocker

    26054 posts

    The offset will work great! Thanks again.

  • #9 / Jun 13, 2011 10:32am

    rhud

    17 posts

    Hi Aaron,

    I’ve tried installing simpledate, but i keep getting the error:

    An Error Was Encountered
    Unable to load the requested class: simpledate

    I’m using MM 1.1.1 and have tried simpledate 1.1 and 1.2.

    I checked that i’m installing addons correctly by installing Fumito Mizuno’s Breadcrumb - and this works fine.

    Any thoughts???

    Thanks

  • #10 / Jun 13, 2011 10:21pm

    Aaron Fowler

    113 posts

    Sorry for the trouble. There seems to be some file permission problems when I upload to Github. I’ve deleted the bad files.

    If you go to the Simpledate Github repository and click Downloads, any of the versions now there should work.

    Aaron

  • #11 / Jun 14, 2011 4:19am

    rhud

    17 posts

    Thanks Aaron - worked a charm!

  • #12 / Feb 03, 2012 7:06am

    karlosb

    43 posts

    Many thanks for this Aaron, excellent stuff!! 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases