WP_Query with UNIX timestamp in meta query
WP_Query with UNIX timestamp in meta query
WP_Query with UNIX timestamp in meta query
Yes, you can do that using PHP. Here’s a function from @arnorhs: $time = strtotime(‘2010-04-28 17:25:43’); echo ‘event happened ‘.humanTiming($time).’ ago’; function humanTiming ($time) { $time = time() – $time; // to get the time since that moment $time = ($time<1)? 1 : $time; $tokens = array ( 31536000 => ‘year’, 2592000 => ‘month’, 604800 … Read more
I don’t think you need to do that, it’s already there (if I understand the question correctly): In the WXR file we get a timestamp like: that’s generated with: <?php the_generator( ‘export’ ); ?> that calls get_the_generator() where the export case is: $gen = ‘<!– generator=”WordPress/’ . get_bloginfo_rss(‘version’) . ‘” created=”‘. date(‘Y-m-d H:i’) . ‘” … Read more
Try passing in a second parameter to tell it to use the GMT offset. current_time( ‘timestamp’, true );
WordPress sets the php timezone to UTC for internal calculations. So at 4pm PST, date() will be producing a date that reads 10pm UTC. Hence the event is considered past. There are two ways to resolve this. (The preferred method) Store dates in the database in UTC. Handle all date calculations in UTC, and convert … Read more
Please use DateTime::getTimestamp() that returns unix timestamp. If you want to format the date according to your time zone then you try this. $datetime = new DateTime(“now”, new DateTimeZone(‘America/New York’)); echo $datetime ->format(‘m/d/Y, H:i:s’);
Timezone for Plugin
Oh you have to wrap in quotes. (time() + 5) Works. Sigh
This is the part that is responsible for random date: //* Generate a random date between January 1st, 2015 and now $random_date = mt_rand( strtotime( ‘1 January 2015’ ), time() ); So you need to change it. And if you want to randomize only the time part, then this is one way to achieve that: … Read more
Just gave an example of how to do it: $today_date = new DateTime( date( ‘Y-m-d’, strtotime( ‘today’ ) ) ); $register_date = get_the_author_meta( ‘user_registered’, get_current_user_id() ); $registered = new DateTime( date( ‘Y-m-d’, strtotime( $register_date ) ) ); $interval_date = $today_date->diff( $registered ); if( $interval_date->days < 31 ) { echo ‘With us ‘ . $interval_date->format(‘%d days’); … Read more