$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>translation - How to translate timestamp?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

translation - How to translate timestamp?

matteradmin12PV0评论

This script comes with the theme I purchased that output "Published 3 days ago on Feb 21, 2019" on the article. However I couldn't get the "%s ago" translated, which includes variables of minute(s), hour(s), day(s), etc. What is the best way to translate just these variables?

<?php esc_html_e( 'Published', 'enews' ); ?>
<?php printf(esc_html__( '%s ago', 'enews' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) );?> 
<?php esc_html_e( 'on', 'enews' ); ?><time itemprop="datePublished" datetime="<?php the_time('Y-m-d'); ?>">
<?php the_time(get_option('date_format')); ?></time>

This script comes with the theme I purchased that output "Published 3 days ago on Feb 21, 2019" on the article. However I couldn't get the "%s ago" translated, which includes variables of minute(s), hour(s), day(s), etc. What is the best way to translate just these variables?

<?php esc_html_e( 'Published', 'enews' ); ?>
<?php printf(esc_html__( '%s ago', 'enews' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) );?> 
<?php esc_html_e( 'on', 'enews' ); ?><time itemprop="datePublished" datetime="<?php the_time('Y-m-d'); ?>">
<?php the_time(get_option('date_format')); ?></time>
Share Improve this question edited Feb 21, 2019 at 3:01 Buramiko asked Feb 21, 2019 at 2:55 BuramikoBuramiko 112 bronze badges 2
  • Which part is not translated? The "ago" word, or the human time diff part? – Krzysiek Dróżdż Commented Feb 21, 2019 at 6:35
  • There is a example in codex which you can use - codex.wordpress/Function_Reference/human_time_diff – anton Commented Feb 22, 2019 at 19:02
Add a comment  | 

1 Answer 1

Reset to default 0

The "%s" will be replaced by strings translated in the WordPress Core "default" text domain. e.g. "%s mins", "%s hours", etc..

Find these in your core translation files and translate them too.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far