
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@cirolee/relative-time
Advanced tools
一个简单的库,用于将日期格式化为相对于当前时间的相对时间字符串。
npm install @cirolee/relative-time
import relativeTime from '@cirolee/relative-time';
// 基本使用
console.log(relativeTime('2025-09-20')); // "1天后"
console.log(relativeTime('2025-09-18')); // "1天前"
console.log(relativeTime(new Date())); // "现在"
// 指定语言环境
console.log(relativeTime('2025-09-20', 'en-US')); // "in 1 day"
console.log(relativeTime('2025-09-18', 'en-US')); // "1 day ago"
relativeTime(date, locale?)
将给定日期格式化为相对于当前时间的相对时间字符串。
date
(string | number | Date): 要格式化的日期locale
(Intl.LocalesArgument, 可选): 语言环境,默认为 'zh-Hans-CN'(string): 格式化后的相对时间字符串
FAQs
A simple library to format dates relative to the current time.
We found that @cirolee/relative-time demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.