Date time doesn’t show correctly in qTranslate [closed]
I agree with Ajay. The plugin isn’t using __()/_e() function
I agree with Ajay. The plugin isn’t using __()/_e() function
Here’s a function you can put in functions.php. function get_current_event() { global $post; $now = get_the_time(‘U’); $year = get_the_time(‘Y’); if($now >= strtotime(“January 1 $year”) && $now < strtotime(“March 1 $year”)) { return get_post_meta($post->ID,’eventA’,true); } if($now >= strtotime(“March 1 $year”) && $now < strtotime(“October 15 $year”)) { return get_post_meta($post->ID,’eventB’,true); } $nextyear = $year+1; if($now >= strtotime(“October … Read more
You have to pass the second parameter $post to get_the_time(‘j’): get_the_time( ‘j’, $post ); If you don’t WordPress will just use whatever the current global post object is.
The key to this is covered on the get_posts codex page: Access all post data using the setup_postdata function: foreach ( $rand_posts as $post ) : setup_postdata($post); Regarding the_date, see the note about multiple instances on a page: SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only … Read more
the_time() doesn’t return the current time, it returns the time of the current post, also it echoes the result. If you need the current time, simply use PHPs native time() function.
Your computer’s time and your server’s time may not be exactly synchronized. So you may be seeing some pseudo-issues because of that. I don’t know where you are seeing “published 1 minute ago”, or anything like that, in the backend. I see a “published on” date and a “last edited” date but those are ‘hard’ … Read more
You could compare post_date to post_modified and only echo your content if they do not match. // inside a Loop if ($post->post_date != $post->post_modified) { ?> <span style=”font-size:85%”>Last update <u><time datetime=”<?php the_modified_time(‘d-m-y’); ?>”> <?php the_modified_time(‘l j F, Y’); ?></time></u></span><?php } If you want “significant” updates, though, you will need to determine what counts as significant … Read more
When using date function it is recommanded to use date format or time format of the installation : get_option(‘time_format’); get_option(‘date_format’); This allows you to grab date format or time format of the current installation.
ACF using milliseconds is not standard for timestamps, and nor is it useful. How much accuracy do you need? Bear in mind that converting to something like yyyymmdd will not accommodate timezones. If you have access to PHPMyAdmin (or similar) and know your way around SQL, running a quick query would probably be the easiest … Read more
You can put a small script in your single.php that updates a custom field with the current time. update_post_meta(get_the_ID(),”last_visit”,time());