• Resolved Denish Patel

    (@ramukaka16)


    Hello,

    I am using one membership plugin and it stores the expiry date in usermeta table with a custom meta key, the meta value is stored in epoch format like “1630627200”

    This is why I can not filter this date with its real value which is: 23-09-2021 or 2021-09-12

    If I filter with 1630627200 then it works, I have checked this Git hook: https://github.com/codepress/admin-columns-hooks/blob/master/snippets/custom-field-unix-dates.php

    I tried change
    $value = strtotime( $value );
    with
    $value = date(‘Ymd’, $value); // also tried Y-m-d

    In the function that is hooked with acp/editing/save_value

    Am I missing something?

    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author Stefan van den Dungen Gronovius

    (@dungengronovius)

    The snippet that you already found should make a custom field column work automatically if it is stored as a timestamp. But it does only affect the Smart Fitlering logic, not the old filter feature where you have the input fields directly on the table. You only need to load the class for the custom field key that you’re using. The snippet does the following things

    1) It makes sure that the value is stored as a timestamp in the database
    2) It makes sure that sorting is done on a numeric value
    3) It tells our smart filtering feature that it needs to map the value to a timestamp so it can be queried correctly.

    Does that help you?

Viewing 1 replies (of 1 total)
  • The topic ‘Unix Timestamp in DB’ is closed to new replies.