Calculate future date
try $future_timestamp = strtotime(‘+1 week’, get_the_date(‘Y-m-d’)); echo date(‘Y-m-d’, $future_timestamp); or $future_timestamp = get_the_date(‘U’) + (60 * 60 * 24 * 7); echo date(‘Y-m-d’, $future_timestamp);
try $future_timestamp = strtotime(‘+1 week’, get_the_date(‘Y-m-d’)); echo date(‘Y-m-d’, $future_timestamp); or $future_timestamp = get_the_date(‘U’) + (60 * 60 * 24 * 7); echo date(‘Y-m-d’, $future_timestamp);
I presume you mean the format of the date that is displayed for the comment. Different themes will do this different ways, but in general there should be a comments.php file which should contain what makes up a comment. In here should be wp_list_comments(); You will need to add a callback in here which will … Read more
To print relative time on posts automatically we can use get_the_date filter. We will check the time difference and print it in human readable form. // Relative date & time function wp_relative_date() { return human_time_diff( get_the_time(‘U’), current_time( ‘timestamp’ ) ) . ‘ ago’; } add_filter( ‘get_the_date’, ‘wp_relative_date’ ); // for posts add_filter( ‘get_comment_date’, ‘wp_relative_date’ ); … Read more
Assuming you want 24 hour time, you want something like jS M Y H:i:s. You can check wordpresses own Formatting Date and Time reference for further details.
You can use the PHP’s strtotime() and WordPress’s date_i18n() functions: function MY_FUNCTION( $input ) { // Removes commas so that we’ll get the proper timestamp. Otherwise, the // strtotime() function would return FALSE. $input = str_replace( ‘,’, ”, $input ); // Retrieve the UNIX timestamp of the date. $timestamp = @strtotime( $input ); // Returns … Read more
This could probably make exquisite debugging session, but taking in account it’s Friday evening – just use date_i18n() instead and let WordPress deal with a huge mess that time/date issues usually are.
Use date_i18n( $format, $i ); echo date_i18n(‘j F Y’, strtotime( $event_date[0] ) ) . ‘ ‘ . date_i18n(‘j F Y’, strtotime( $event_from_time[0] ) ) . ‘ do ‘ . date_i18n(‘j F Y’, strtotime( $event_to_time[0] ) ); See also: How to integrate get_post_time with date_i18n function?
Upgrade to PHP 5.2 or above The Error Message you see is by WordPress. It’s very misleading what it basically saying is, that you need a PHP version >= 5.2 for that feature to work. Please look into your operating systems documentation or contact technical support on how to update your PHP version. For CentOS, … Read more
I don’t see anything like it in the database, so you probably have to do this yourself. To save the last login time, you can hook into the wp_login action, and save a user meta value (like [myprefix]_lastlogintime). You first read this value, so you get the previous login time, save this in the session, … Read more
get_the_date and/or get_the_time will return the date/time of the post rather than printing it.