如何将数据库的nepali日期转换为英文日期?

时间:2014-08-13 07:20:51

标签: mysql

任何人都可以指导我如何将数据库的nepali日期转换为英文日期。

数据库在这里:

id  date
1   2071/12/21
2   2071/9/15 

3 个答案:

答案 0 :(得分:0)

因此,就公式本身而言,它在这里描述: http://www.mypatro.com/date-converter.html

如果您告诉我们您尝试将其转换为何种语言(编程语言和\或SQL方言,如MySQL,MSSQL等),我可以尝试帮助将公式转换为实际代码。

编辑:

假设$ result包含你的sql结果;

$formatted_data = array();
while ($row = pg_fetch_assoc($result)) {
    $nepali_date = strtotime($row['date']);
    $english_date = strtotime("-56 years 8 months 16 days",$nepali_date)
    $formatted_data['english_date'] = $english_date;
}

答案 1 :(得分:0)

要进行近似转换,请减去56年,8个月和16天:

select
    id,
    date - interval '56 year' 
         - interval '8 month'
         - interval '16 day' as date
from mytable

答案 2 :(得分:0)

再次将strtotime转换为格式化日期: