Time & Date on Post – Time Ago Custom Function
$mytimestamp = date(get_option(‘date_format’), strtotime($date)) . ‘ at ‘ . date(get_option(‘time_format’), strtotime($date));
$mytimestamp = date(get_option(‘date_format’), strtotime($date)) . ‘ at ‘ . date(get_option(‘time_format’), strtotime($date));
Yes, escaping everything (and as close to output as possible) is a way to go. Right until the point excessive escaping is causing issues in specific circumstances. Note that while this happens in context of attribute, esc_url() is more fitting for URLs. Always use esc_url when sanitizing URLs (in text nodes, attribute nodes or anywhere … Read more
Used date_i18n instead of current_time. For example: echo date_i18n( ‘Y. F j.’, strtotime( get_the_time( “Y-m-d” ) ) );
Two ways at least: Method 1 If you happy to accept the latest of all the wp posts ‘last modified’ as the date that the site was last updated, then you could add a function to get the latest of the ‘post_modified’ in the posts table and add that to your header.php either in the … Read more
That format is almost readable by strtotime. Remove the commas and it will convert. $t=”27 January, 2012, 5:05 AM”; $t = str_replace(‘,’,”,$t); $t = strtotime($t); echo date(‘Y-m-d H:i:s’,$t);
There was an issue with the code originally posted by kaiser in that it queried for year, month and day distinctly resulting in values representing “the largest month for any date” or the “smallest day for any date” rather than values representing the MAX and MIN dates globally. I altered that original code to query … Read more
I believe you’re using the wrong function. get_the_time() doesn’t actually return the current time but instead the time of when the post was published. Maybe what you’re looking to use is date( ‘H’ ).
Try this: <?php $archive_year = get_the_time(‘Y’); $archive_month = get_the_time(‘m’); $archive_day = get_the_time(‘d’); ?> <a href=”https://wordpress.stackexchange.com/questions/201844/<?php echo get_day_link( $archive_year, $archive_month, $archive_day); ?>”><?php the_date(‘Y/m/d’); ?></a> HTML result: <a href=”http://example.com/2015/09/07″>2015/09/07</a>
This is not a WordPress question, but to help you out: function displaydate() { return date( ‘d/m/Y G:i’, strtotime( ‘-6 hours’ ) ); } add_shortcode(‘date’, ‘displaydate’); The shortcode itself should work fine.
I believe all the info you need is in the PHP Manual for Date/Time. Also, it is recommended that you use get_the_date(); instead of the_date(); Get them month in 3 cap letters? M is the right format character that outputs a short textual representation of a month (3 chars). Why can’t you use CSS to … Read more