How to integrate get_post_time with date_i18n function?

Use the fourth parameter for get_post_time(): $time = get_post_time( ‘F j, Y’, // format TRUE, // GMT get_the_ID(), // Post ID TRUE // translate, use date_i18n() ); get_post_time() calls mysql2date() internally, and it passes the $translate argument through. In mysql2date() we find this: if ( $translate ) return date_i18n( $format, $i ); So, all you … Read more

The purpose of the post_date_gmt?

Some countries use a Daylight Saving Time (DST): Typically clocks are adjusted forward one hour near the start of spring and are adjusted backward in autumn. Sometimes there is no 2 am. Sometimes you get 2 am two times. To avoid cron jobs running twice or not at all WP needs the GMT (or more … Read more

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

Convert number to month name in PHP

The recommended way to do this: Nowadays, you should really be using DateTime objects for any date/time math. This requires you to have a PHP version >= 5.2. As shown in Glavić’s answer, you can use the following: The ! formatting character is used to reset everything to the Unix epoch. The m format character is the numeric representation of a month, … Read more

How do I use PHP to get the current year?

You can use either date or strftime. In this case I’d say it doesn’t matter as a year is a year, no matter what (unless there’s a locale that formats the year differently?) For example: On a side note, when formatting dates in PHP it matters when you want to format your date in a different locale than … Read more

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