Show different time stamp based on time

Check out human_time_diff(): if ( DAY_IN_SECONDS < ( $time = current_time( ‘timestamp’ ) ) – ( $time_post = get_the_time( ‘U’ ) ) ) echo human_time_diff( $time_post, $time ) . ‘ ago’; else the_time( ‘F j, Y at g:i a’ ); DAY_IN_SECONDS is a handy “helper” constant in WordPress, along with: MINUTE_IN_SECONDS HOUR_IN_SECONDS WEEK_IN_SECONDS YEAR_IN_SECONDS

How to get its meta_value of a specific meta_key within wp_usermeta

@Cristián Lávaque Thank you for the hints 😉 Actually I managed to resolve the issue blocking this function (show the hidden comment above). In case this would help anyone here is the final working code: function check_post_limit() { if ( current_user_can( ‘edit_posts’ ) ) { global $userdata; global $wpdb; $s2member_last_payment_time = get_user_meta( get_current_user_id(), ‘wp_s2member_last_payment_time’, true … Read more

WP Query and date format

For those who experienced the same problem, I finally found a way to do the sort. First I created an extra CMB like this : $cmb->add_field( array( ‘id’ => $prefix . ‘session_gooddatebegin’, ‘type’ => ‘hidden’, ) ); Then I created an action using save_post. If the CPT “session” is being updated, thanks to $update, I … Read more

How to show different timestamp

This should do it. // See if the post is older than 24 hours. if ( get_post_time() <= strtotime( ‘-1 day’ ) ) { echo ‘Published more than 24 hours ago.’; } else { echo ‘Published within the last 24 hours.’; }

Woocomerce pulling wrong time from server -5 hrs difference

For the date Woocommerce CODE function wc_string_to_datetime( $time_string ) { // Strings are defined in local WP timezone. Convert to UTC. if ( 1 === preg_match( ‘/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|((-|\+)\d{2}:\d{2}))$/’, $time_string, $date_bits ) ) { $offset = ! empty( $date_bits[7] ) ? iso8601_timezone_to_offset( $date_bits[7] ) : wc_timezone_offset(); $timestamp = gmmktime( $date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1] ) – … Read more