PersianTime:伊朗时间和日期格式设置的首选 JavaScript 库
这个轻量级实用程序可以轻松地将任何日期或时间转换为伊朗当地时间,并以熟悉的波斯日期格式显示。 非常适合针对伊朗用户或需要无缝波斯日历集成的应用程序。
主要特点:
安装:
通过 npm 安装:
<code class="language-bash">npm install persiantime</code>
或纱线:
<code class="language-bash">yarn add persiantime</code>
使用示例:
格式化日期:
<code class="language-javascript">import { PersianTime } from 'persiantime'; const persianDate = PersianTime(new Date('2025-01-20T11:05:20.451Z')); console.log(persianDate); // Output: Persian formatted date and time</code>
处理 API 日期(ISO 格式):
<code class="language-javascript">import { PersianTime } from 'persiantime'; const creationTime = PersianTime(new Date(document.created_at)); const updateTime = PersianTime(new Date(document.updated_at)); console.log(creationTime); console.log(updateTime);</code>
为什么选择波斯时间?
贡献:
我们欢迎贡献! 分叉存储库,进行改进并提交拉取请求。在 GitHub 存储库上报告问题或建议功能。
表达您的支持:
在 GitHub 上为项目加注星标,并在 npm 上留下评论,以帮助我们继续开发并添加新功能。
链接:
感谢您使用波斯时间!
以上是在 React 中将日期转换为波斯时间的详细内容。更多信息请关注PHP中文网其他相关文章!