Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Sort by Unix Timestamp Not Working

Viewing 6 posts - 1 through 6 (of 6 total)
  • Matt Harris
    #195465

    I am saving a unix timestamp for a custom post type. When I set the posts to sort by “meta value” and select the corresponding “meta key” and then set it to be “descending” and “numeric” the posts seem to be randomly sorted. Is there an issue reading Unix Timestamps? They are numerically incremental, so this doesn’t make any sense to me.

    Trevor Moderator
    #195479

    I am sorry, but we do not support timestamps at this version of the plugin, only dates. The only ‘date’ that can be sorted in the Posts settings tab is the Post Date. Any Post Meta data that is a date needs to be saved as a SQL date, in this format: YYYYMMDD and then sorted as a number.

    Your times would need to be stored in a similar way (as numbers). E.g 3:15PM and 30 seconds would have to be stored in the 24 hour clock like this: 151530. Then that can be sorted.

    So, combining that time with today’s date would be 20181206151530.

    Riccardo
    #211836

    Hi, I’m using the latest version of this plugin. It seems that this problem still exists (just in the DESC case, not in the ASC one). Please, could me explain why I can’t sort posts by Unix timestamps if these timestamps are numbers? I think that using meta_value_num should be enough (in the Post Meta tab it works for filtering). Thank you.

    Trevor Moderator
    #211842

    Our plugin does not support Unix Timestamps in this usage, I am sorry.

    Reginald Lloyd-Jones
    #227293

    For anyone else having this issue, it seems you can currently sort by a unix timestamp by selecting “alphabetical”. Unfortunately the ascending/descending controls seem to have no effect and your results will always show up in descending order (Most Recent first).

    Unix timestamps are literally just a number which if sorted normally would give us the desired result, so it seems silly to say that it’s not supported, as the website says you can sort a metadata field numerically. In my case I’m curious if the issue is being caused by the timestamp being stored in a single value array:

    array (
      0 => '1568643510',
    )

    I’m going to do some tests and see if the S&F works correctly with simple numbers stored as meta-data. I’ll let you know if I find anything interesting.

    Trevor Moderator
    #227303

    That could well be the issue, as our plugin only sorts fields that have non-array single values, AFAIK. For example, taxonomies are stored as arrays, and so cannot be sorted.

Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.