How to get date for each post?

I ran into the same problem several times, following changes worked for me in the past: while (have_posts()) : the_post(); //some html <li class=”icon-date”><?php echo get_the_date( ‘Y-m-d’ ); ?></li> <li class=”icon-time”><?php the_time( ‘H:i:s’ ); ?></li> Instead of the_date(), use get_the_date(). The only thing to be aware of, is that values returned by get_the_date() have to … Read more

Unable to select an old date in wordpress

This is not really an answer, just an attempt to find the specific context for this problem. Please install the following plugin on your site, try to set the three dates and add your result to the second <pre> in the table below. /* Plugin Name: WPSE Sysinfo */ add_action( ‘admin_footer’, ‘wpse_sysinfo’ ); function wpse_sysinfo() … Read more

Proper formatting of post_date for wp_insert_post?

If you don’t add a post_date then WordPress fills it automatically with the current date and time. To set another date and time [ Y-m-d H:i:s ] is the right structure. An example below with your code. $postdate=”2010-02-23 18:57:33″; $new_post = array( ‘post_title’ => $title, ‘post_content’ => $description, ‘post_date’ => $postdate, ‘post_status’ => ‘publish’, ‘post_parent’ … Read more

Converting timestamps to local time with date_l18n()

I know I’m three months late, but the function you want here is WordPress’ get_date_from_gmt(). The function accepts a GMT/UTC date in Y-m-d H:i:s format as the first parameter, and your desired date format as the second parameter. It’ll convert your date to the local timezone as set on the Settings screen. Example usage: echo … Read more

How to get WordPress Time Zone setting?

if you need the gmt_offset then <?php echo get_option(‘gmt_offset’); ?> this will give you an integer like 2 or -2. and if you need the timezone string use <?php echo get_option(‘timezone_string’); ?> this will give you a string like America/Indianapolis