如何在PHP中将Hijri日期转换为gregorian? [英] How can I convert Hijri date to gregorian in PHP?

查看:80
本文介绍了如何在PHP中将Hijri日期转换为gregorian?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将此日期:09/13/1436(是Hijiri)转换为2015-06-30(是格里高利历)。
我尝试过:

I would like convert this date:09/13/1436 (it is Hijiri) to 2015-06-30(it is Gregorian). I tried that:

function HijriToJD($m, $d, $y){
   return (int)((11 * $y + 3) / 30) + 354 * $y + 
     30 * $m - (int)(($m - 1) / 2) + $d + 1948440 - 385;
}


$date = HijriToJD(09, 13, 1436);

echo jdtogregorian($date);

当我进行编译时,我得到了2014/10/7。
有人有什么想法吗?

and when i made compile i got 10/7/2014. Someone have any idea??

推荐答案

通过 09 因为月份是个问题。...对待带有前导零的数字在PHP中为八进制 09 是无效的八进制,因此将其视为 0

Passing 09 as the month is the problem.... a number with a leading zero is treated as octal in PHP. 09 is invalid octal, so it is treated as a 0.

呼叫

$r=HijriToJD(9, 13, 1436);

(本月没有前导零)应该给您正确的结果

(without the leading zero for the month) should give you a correct result

这篇关于如何在PHP中将Hijri日期转换为gregorian?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆