Skip to main content

๐Ÿˆ Friendly Format

zjkalLess than 1 minute

๐Ÿˆ Friendly Format

Tips

It is generally used on social platforms, comments, forums, etc

toFriendly()

Returns a friendly date format, such as N seconds ago

Parameters

ParameterIntroductionRequire
timeAny type of string time or timestamprequired
langLanguage: zh for Chinese, en for EnglishOptional, the default value is zh

Return Values

Friendly date format

Example code

/* Convert to a friendly date format */
TimeHelper::toFriendly('2022-3-2 10:15:33');
// 3ๅคฉๅ‰

/* Convert to a friendly date format */
TimeHelper::toFriendly(1646186290, 'en');
// 6 hours ago