Answer the question
In order to leave comments, you need to log in
How to add post time to wordpress function?
There is a code:
add_filter('the_time', 'dynamictime'); function dynamictime() {
global $post;
$date = $post->post_date;
$time = get_post_time('G', true, $post);
$mytime = time() - $time;
if($mytime > 0 && $mytime < 1*24*60*60) $mytimestamp = sprintf(__('%s ago'), human_time_diff($time));
else $mytimestamp = date(get_option('date_format'), strtotime($date)); return $mytimestamp;
}
Answer the question
In order to leave comments, you need to log in
date_format
and time_format
are set in the admin panel in the settings section.
$date_format = get_option('date_format');
$time_format = get_option('time_format');
$mytimestamp = date("{$date_format} {$time_format}", strtotime($date));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question