Giter Club home page Giter Club logo

Comments (3)

sy-records avatar sy-records commented on June 2, 2024

这是主题作者需要干的事情,你是用的默认主题吗?

from typecho.

vimbackground avatar vimbackground commented on June 2, 2024

我指的列表是系统后台的文章列表,不是指的前台主题。

from typecho.

sy-records avatar sy-records commented on June 2, 2024

超过一个星期就是年月日了

public static function dateWord(int $from, int $now): string
{
$between = $now - $from;
/** 如果是一天 */
if ($between >= 0 && $between < 86400 && date('d', $from) == date('d', $now)) {
/** 如果是一小时 */
if ($between < 3600) {
/** 如果是一分钟 */
if ($between < 60) {
if (0 == $between) {
return _t('刚刚');
} else {
return str_replace('%d', $between, _n('一秒前', '%d秒前', $between));
}
}
$min = floor($between / 60);
return str_replace('%d', $min, _n('一分钟前', '%d分钟前', $min));
}
$hour = floor($between / 3600);
return str_replace('%d', $hour, _n('一小时前', '%d小时前', $hour));
}
/** 如果是昨天 */
if (
$between > 0
&& $between < 172800
&& (date('z', $from) + 1 == date('z', $now) // 在同一年的情况
|| date('z', $from) + 1 == date('L') + 365 + date('z', $now))
) { // 跨年的情况
return _t('昨天 %s', date('H:i', $from));
}
/** 如果是一个星期 */
if ($between > 0 && $between < 604800) {
$day = floor($between / 86400);
return str_replace('%d', $day, _n('一天前', '%d天前', $day));
}
/** 如果是 */
if (date('Y', $from) == date('Y', $now)) {
return date(_t('n月j日'), $from);
}
return date(_t('Y年m月d日'), $from);
}

如果需要显示你的方案,84行直接return

        return date('m月d日 H:i', $from);

from typecho.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.