Results 1 to 7 of 7

Thread: Age output instead of date in FE

  1. #1
    User
    Join Date
    08-04-09.
    Posts
    230

    Default Age output instead of date in FE

    When creating a date field in the catalog, is it possible to have it display the age of a person instead of the date?

  2. #2
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Age output instead of date in FE

    You can use the version 2.0 Alpha and then add a Calculated field, but you'll have to know SQL to be able to write your age calculation from the birthday.

    birthdate = 124315315 (let's say its 1969-10-20)
    age = (-TIMESTAMPDIFF(YEAR, CURDATE(),DATE(FROM_UNIXTIME(birthdate))))

  3. #3
    User
    Join Date
    08-04-09.
    Posts
    230

    Default Re: Age output instead of date in FE

    Thanks! I'll give it a go

  4. #4
    User
    Join Date
    06-20-09.
    Location
    Middlesbrough, UK
    Posts
    246

    Default Re: Age output instead of date in FE

    Could you use SQL to display the date like this: Monday 1st January 2010?

    This would be great for displaying dates in a catalogue i have for some courses.
    360fusion: Virtual Tours - Web Design
    Social Media: Twitter - Facebook Page

  5. #5
    User
    Join Date
    06-20-09.
    Location
    Middlesbrough, UK
    Posts
    246

    Default Re: Age output instead of date in FE

    I was able to turn the Unix time from the catalog date picker to display the date like this: Monday 1st April 2010.

    I did this by adding some php to the template

    This is the usual echo code:
    <?php echo $entry['data']['service_date_date'']['value'];?>

    service_date_date being the name of the catlogue field

    I changed it to this:
    <?php echo date("l jS F Y", $entry['data']['service_date_date']['value']);?>

    Other things you can do can be found here: http://php.net/manual/en/function.date.php

    I'm not a developer so can't explain more than this. hope someone else finds it useful.
    360fusion: Virtual Tours - Web Design
    Social Media: Twitter - Facebook Page

  6. #6
    Experienced user
    Join Date
    06-10-09.
    Location
    Cape Town, South Africa
    Posts
    1,387

    Default Re: Age output instead of date in FE

    Hey Ben

    Now you're just being silly. The Catalog has always included the ability to format a date. Just enable formatting and then select DATE and then choose the date string. Its automated!

  7. #7
    User
    Join Date
    06-20-09.
    Location
    Middlesbrough, UK
    Posts
    246

    Default Re: Age output instead of date in FE

    Dear god!

    I'm sure I even knew this. There's just to many features in typolight and it's modules to remember.
    360fusion: Virtual Tours - Web Design
    Social Media: Twitter - Facebook Page

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •