Skip to content

Datetime sometimes stored in DB incorrectly #7417

@russell-edsvcs

Description

@russell-edsvcs

Description

I have the following code in my plugin

add_action('init', function(){
    $post_id = 8913;
    $date1 = strtotime('yesterday');
    $date2 = strtotime('tomorrow');
    $pod = pods('action', $post_id);
    
    $pod->save('scheduled_for', $date1);
    $datetime = $pod->field('scheduled_for');
    echo $datetime;
    echo '<br>';

    $pod->save('scheduled_for', $date2);
    $datetime = $pod->field('scheduled_for');
    echo $datetime;
    echo '<br>';

    $pod->save('scheduled_for', $date1);
    $datetime = $pod->field('scheduled_for');
    echo $datetime;
    echo '<br>';
    
    exit;
});

It is producing the output

1744329600
2400-04-12 17:44:50
1744329600

Expected:
It should produce data stored in one format or the other.

What I'm seeing:
Dates for today are being stored as a timestamp. Dates for tomorrow are being stored as a formatted date. I can verify in a database viewer that the data is getting stored in the database wrong, so it is an issue with the way Pods is storing the data, and not the way it is retrieving it.

Here are my pods settings for this field:

Image

Version

3.2.8.2

Testing Instructions

No response

Screenshots / Screencast

No response

Possible Workaround

No response

Site Health Information


Pods Package

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions