Styling the date format with date_i18n

Just use date_i18n in multiple places with PHP date arguments just for what you need: if ( $date = get_post_meta( $thepostid, ‘_sale_price_dates_to’, true ) ) { $sale_price_dates_to = ‘<span class=”m”>’ . date_i18n( ‘M’, $date ) . ‘</span> ‘ . ‘<span class=”d”>’ . date_i18n( ‘j’, $date ) . ‘</span> ‘ . ‘<span class=”y”>’ . date_i18n( ‘Y’, … Read more

Datepicker not supporting timepicker

WordPress supports only datepicker. If you want to add timepicker in datepicker you have to use jquery-ui-timepicker-addon as extension in your theme or plug-in. Add css and js as below add_action(‘wp_enqueue_scripts’, ‘custom_datepicker’); function custom_datepicker() { //wp_enqueue_script(‘jquery-ui-datepicker’); //wp_enqueue_script(‘jquery-ui-core’); wp_enqueue_script(‘jquery-ui-timepicker-addon’,get_stylesheet_directory_uri().’/js/jquery-ui-timepicker-addon.js’,array()); wp_enqueue_style(‘jquery-ui-timepicker-addon’,get_stylesheet_directory_uri().’/css/jquery-ui-timepicker-addon.css’,array()); wp_enqueue_style(‘jquery-ui’,get_stylesheet_directory_uri().’/css/jquery-ui.css’,array()); } You can download all css and js files from this link http://trentrichardson.com/examples/timepicker/ Call timepicker … Read more

Use meta_query to display events by date in custom field

Simpler CODE: Logically, when you check >= for both _event_start_date and _event_end_date, that automatically covers the BETWEEN check. So the following CODE should work: $termName = get_queried_object()->name; $termSlug = get_queried_object()->slug; $event1 = current_time( ‘Y-m-d’ ); $args = array( ‘post_type’ => ‘event’, ‘event-categories’ => $termSlug, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 10, ‘order’ => ‘ASC’, ‘meta_query’ => … Read more

How to get time difference between publish date and now?

Try the date_diff() / DateTime::diff() function in PHP: // Object-oriented style. $datetime1 = new DateTime( $post->post_date ); $datetime2 = new DateTime(); // current date $interval = $datetime1->diff( $datetime2 ); echo $interval->format( ‘%a days old’ ); // .. or procedural style. $datetime1 = date_create( $post->post_date ); $datetime2 = date_create(); // current date $interval = date_diff( $datetime1, … Read more

How to get the latest posting time of archived pages in WordPress?

Query the posts ordered by date, restricted to 1 post to display, then get the date. $args = array( ‘posts_per_page’ => 1, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ); $lastpost = get_posts($args); echo $lastpost[0] -> post_date; Edited last line for proper display: $lastpostdate = $lastpost[0] -> post_date; echo ‘<div class=”lastpostdate>”‘ . $lastpostdate . ‘</div>’; Or, … Read more

Finding difference in days

You should store the time as a unix time stamp then you can use human_time_diff to compare. echo human_time_diff( get_the_time(‘U’), current_time(‘timestamp’) ); If the difference is more than 24 hours difference it will return the value in days.

Custom Field sort not working (WP 3.8.1)

I think your query arguments are missing meta_key, which in this case should be ‘event-date’. You need it outside the meta query for orderby to work. Try this: $today = date(“Ymd”, strtotime(current_time(‘mysql’))); $args = array( “post_type” => “post”, “post_status” => “publish”, “posts_per_page” => -1, “cat” => 13, “meta_query” => array( array( “key” => “event-date”, ‘type’ … Read more

Date query not inclusive despite parameter being true

If you only want to work with yyyy-mm-dd strings, for example ‘2014-10-10’, you could do something like: ‘before’ => ‘2014-10-10 + 1 day – 1 second’, ‘before’ => ‘2014-10-10 + 86399 seconds’, ‘before’ => ‘tomorrow 2014-10-10 – 1 second’, ‘before’ => ‘2014-10-10 tomorrow – 1 second’, or just append ’23:59:59′ to your yyyy-mm-dd string to … Read more

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