TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

JDateTime - Iranian (Shamsi) Date for PHP

29 点作者 sallar超过 12 年前
jDateTime is a PHP wrapper for DateTime class enabling developers to use Iranian date/time in their projects.

5 条评论

amir超过 12 年前
You know you can do this:<p><pre><code> $idf = new IntlDateFormatter('fa_IR@calendar=persian', IntlDateFormatter::FULL, IntlDateFormatter::FULL,"Asia/Tehran", IntlDateFormatter::TRADITIONAL); </code></pre> right?<p>PHP has a wrapper for ICU.
评论 #5271342 未加载
revelation超过 12 年前
Thank god they finally introduced all this classes and inheritance kerfuffle in PHP, so we can now manually handle Iranian dates by calling "toJalali" on a pseudo-singleton "jDateTime" class.<p>In all seriousness, I wanted to punch myself in the face when I had to instantiate a "GregorianCalendar" in Java, but the general idea has a lot of merit, even if the implementation is terrible.
maxcan超过 12 年前
not to be confused with JDate.com..
评论 #5271315 未加载
评论 #5271347 未加载
phishphood超过 12 年前
don't know much about how Iranian dates work so I peeked inside the code to see the actual conversion.<p>Line 482 - $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);<p>Umm, what about leap years, you know the ones that have 29 days in February?
评论 #5271957 未加载
afshinmeh超过 12 年前
upvote, you rock Sallar :)