Skip Navigation

[Résolu] What format does Types save dates in?

This support ticket is created Il y a 4 années et 12 mois. There's a good chance that you are reading advice that it now obsolete.
Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 0 réponses, has 1 voix.

Last updated by davidR-12 Il y a 4 années et 12 mois.

Assisted by: Waqar.

Auteur
Publications
#1236048

I have a date field that I am trying to access via PHP code. I need to know what format Types saves its date fields in to do this. The code is designed to delete posts once the date field value has been reached:

add_action( 'wp', 'expire_events_daily' );
function expire_events_daily() {
    if ( ! wp_next_scheduled( 'delete_expired_events' ) ) {
        wp_schedule_event( time(), 'hourly', 'delete_expired_events');
    }
}
add_action( 'delete_expired_events', 'delete_expired_events_callback' );

function delete_expired_events_callback() 
{
    $args = [
        'post_type'      => 'job',
        'posts_per_page' => -1,
        'fields'         => 'ids', //only get post id's
        'meta_query'     => [
            [
               'key'     => 'job-closing-date',
               'value'   => current_time( 'Y/m/d' ),
               'compare' => '<'
            ]
        ]
    ];

    $events = get_posts( $args );

    if ( $events ) {
        // Loop through the post ID's and delete the post
        foreach ( $events as $id )
            wp_delete_post( $id );
    }
}

As you can see I am using

'value'   => current_time( 'Y/m/d' ),

And need to know if this is the way that Types saves dates.

Regards,

David

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.