Get system timestamp in wordpress

You can use PHP’s date() function here, but usually first you’ll need to run date_default_timezone_set. UTC+1 looks like Central Europe time from what I can tell, so here’s what I’d run: <?php date_default_timezone_set(‘Europe/Berlin’); echo date( ‘D, d M Y H:i:s’, now() ); ?> That will print out the current time from your server. If you’re … Read more

Make datestamp for status updates show time

Just go to Settings > General, scroll down to the date formatting section, select custom, and type this: F jS, g:i a which yields a date like: June 1st, 7:29 pm The official WordPress docs give the letters to use for time formatting.

How to change post date only 1 time a day?

Compare the post_date with the current time and then test if the difference is greater than one day: is_admin() or add_action( ‘the_post’, function( $post ) { if ( ! is_singular() or ! is_main_query() ) return; // now minus last mod time in seconds $diff = time() – mysql2date( ‘U’, $post->post_date ); if ( DAY_IN_SECONDS >= … Read more

Time sort with meta_key using UNIX timestamp failing due to date differences

I will caveat this by saying that I am still not 100% sure I know what you are doing, but I believe the following will sort your results by time only assuming that your meta values are proper Unix timestamps. function orderby_time_only($orderby) { remove_action(‘posts_orderby’,’orderby_time_only’); return preg_replace(‘|(.*)\s(.*)|’,’DATE_FORMAT(FROM_UNIXTIME($1),”%k%i”) $2′,$orderby); } add_filter(‘posts_orderby’,’orderby_time_only’); $args = array( ‘post_type’ => ‘event’, … Read more

How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp

I’m outlining a solution for what you asked in your last comment, because this wouldn’t been fitting for the comment format. Code: function date_time_to_timestamp_meta( $post_id ) { // meta fields are saved in DATETIME, e.g. »2013-12-09 22:32:12« // here is only the date part relevant $datetime_date = get_post_meta( $post_id, ‘_start_date’, true ); // here is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)