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.

Custom field equal to current time

February 17, 2012 9:33am

Subscribe [2]
  • #1 / Feb 17, 2012 9:33am

    eddyfever

    62 posts

    I have a custom field which is a date field called deadline.
    Now i wanna show those entries which have the deadline of today’s date.

    i tried something like this but with no success, does somebody has a idea?
    Thank you already for your time.

    {if deadline == "{current_time format="%d/%m/%y"}"}
    ...
    {/if}

    note: the date is not the standard date field, but a custom field.

  • #2 / Feb 17, 2012 1:11pm

    Mark Bowen

    12637 posts

    As date fields are stored with hours minutes and seconds too in Unix timestamp format then the above code won’t work as you will be comparing a quite large number against what isn’t really a number but an artificial date.

    What you’ll need to do to get this working is something like this :

    {if "{deadline format='%d/%m/%y'}" == "{current_time format='%d/%m/%y'}"}
    Do this…
    {/if}

    This will then take both dates and create them into the same format for you essentially stripping the hours, minutes and seconds from both instead of just the current_time variable.

    Hope that helps a bit.

    Best wishes,

    Mark

     

  • #3 / Feb 17, 2012 2:31pm

    eddyfever

    62 posts

    Perfect! That is the way to do it. Thank you.

  • #4 / Feb 18, 2012 5:28am

    Mark Bowen

    12637 posts

    No problem at all. Glad that got you all sorted.

    Best wishes,

    Mark

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

ExpressionEngine News!

#eecms, #events, #releases