修改文章发布时间具体到小时分钟秒

把beign主题依次打开inc文件夹里的function文件夹里面的function.php文件,找到“// 时间”。把如下代码

下图是修改之前的效果

修改文章发布时间具体到小时分钟秒

  1. if?(zm_get_option('meta_time'))?{
  2. function?time_ago(?$time_type?){
  3. ????switch(?$time_type?){
  4. ????????case?'comment':?//评论时间
  5. ????????????????printf(__('%1$s?at?%2$s'),?get_comment_date(),??get_comment_time());
  6. ????????????break;
  7. ????????case?'post';?//日志时间
  8. ????????????????echo?get_the_date();
  9. ????????????break;
  10. ????????case?'posts';?//日志时间年
  11. ????????????????echo?get_the_date();
  12. ????????????break;
  13. ????}
  14. }
  15. }?else?{
  16. function?time_ago(?$time_type?){
  17. ????switch(?$time_type?){
  18. ????????case?'comment':?//评论时间
  19. ????????????$time_diff?=?current_time('timestamp')?-?get_comment_time('U');
  20. ????????????if(?$time_diff?<=?300?)
  21. ????????????????echo?('刚刚');
  22. ????????????elseif(??$time_diff>=300?&&?$time_diff?<=?86400?)?//24?小时之内
  23. ????????????????echo?human_time_diff(get_comment_time('U'),?current_time('timestamp')).'前';
  24. ????????????else
  25. ????????????????printf(__('%1$s?at?%2$s'),?get_comment_date(),??get_comment_time());
  26. ????????????break;
  27. ????????case?'post';?//日志时间
  28. ????????????$time_diff?=?current_time('timestamp')?-?get_the_time('U');
  29. ????????????if(?$time_diff?<=?300?)
  30. ????????????????echo?('刚刚');
  31. ????????????elseif(??$time_diff>=300?&&?$time_diff?<=?86400?)?//24?小时之内
  32. ????????????????echo?human_time_diff(get_the_time('U'),?current_time('timestamp')).'前';
  33. ????????????else
  34. ????????????????echo?the_time(?'m月d日'?);
  35. ????????????break;
  36. ????????case?'posts';?//日志时间年
  37. ????????????$time_diff?=?current_time('timestamp')?-?get_the_time('U');
  38. ????????????if(?$time_diff?<=?300?)
  39. ????????????????echo?('刚刚');
  40. ????????????elseif(??$time_diff>=300?&&?$time_diff?<=?86400?)?//24?小时之内
  41. ????????????????echo?human_time_diff(get_the_time('U'),?current_time('timestamp')).'前';
  42. ????????????else
  43. ????????????????echo?get_the_date();
  44. ????????????break;
  45. ????}
  46. }
  47. }

直接替换成

下图是修改之后的效果

修改文章发布时间具体到小时分钟秒

  1. if?(zm_get_option('meta_time'))?{
  2. function?time_ago(?$time_type?){
  3. ????switch(?$time_type?){
  4. ????????case?'comment':?//评论时间
  5. ????????????????printf(__('%1$s?at?%2$s'),?get_comment_date(),??get_comment_time());
  6. ????????????break;
  7. ????????case?'post';?//日志时间
  8. ????????????????echo?get_the_date();
  9. ????????????break;
  10. ????????case?'posts';?//日志时间年
  11. ????????????????echo?the_time(?'m月d日'?);
  12. ????????????????echo?the_time('H:i:s');
  13. ????????????break;
  14. ????}
  15. }
  16. }?else?{
  17. function?time_ago(?$time_type?){
  18. ????switch(?$time_type?){
  19. ????????case?'comment':?//评论时间
  20. ????????????$time_diff?=?current_time('timestamp')?-?get_comment_time('U');
  21. ????????????if(?$time_diff?<=?300?)
  22. ????????????????echo?('刚刚');
  23. ????????????elseif(??$time_diff>=300?&&?$time_diff?<=?86400?)?//24?小时之内
  24. ????????????????echo?human_time_diff(get_comment_time('U'),?current_time('timestamp')).'前';
  25. ????????????else
  26. ????????????????printf(__('%1$s?at?%2$s'),?get_comment_date(),??get_comment_time());
  27. ????????????break;
  28. ????????case?'post';?//日志时间
  29. ????????????$time_diff?=?current_time('timestamp')?-?get_the_time('U');
  30. ????????????if(?$time_diff?<=?300?)
  31. ????????????????echo?('刚刚');
  32. ????????????elseif(??$time_diff>=300?&&?$time_diff?<=?86400?)?//24?小时之内
  33. ????????????????echo?human_time_diff(get_the_time('U'),?current_time('timestamp')).'前';
  34. ????????????else
  35. ????????????????echo?the_time(?'m月d日'?);
  36. ????????????????echo?the_time('H:i:s');
  37. ????????????break;
  38. ????????case?'posts';?//日志时间年
  39. ????????????$time_diff?=?current_time('timestamp')?-?get_the_time('U');
  40. ????????????if(?$time_diff?<=?300?)
  41. ????????????????echo?('刚刚');
  42. ????????????elseif(??$time_diff>=300?&&?$time_diff?<=?86400?)?//24?小时之内
  43. ????????????????echo?human_time_diff(get_the_time('U'),?current_time('timestamp')).'前';
  44. ????????????else
  45. ????????????????echo?get_the_date();
  46. ????????????break;
  47. ????}
  48. }
  49. }

这样就完成了。

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: