0

Can any one guide me how to convert the nepali date of database in to english date.

Database is here:

id  date
1   2071/12/21
2   2071/9/15 
5
  • no i dont want output. i want the process to convert this database date into english date
    – Ash
    Aug 13, 2014 at 7:26
  • 2
    what is Your expected Format of the date? Aug 13, 2014 at 7:27
  • 2014/8/13 this is what i want
    – Ash
    Aug 13, 2014 at 7:30
  • Plz elaborate the your format. How is the date and month are coming? Aug 13, 2014 at 7:33
  • year/month/day this is what i want
    – Ash
    Aug 13, 2014 at 7:36

3 Answers 3

0

So, as far as the formula itself goes, it's described here: http://www.mypatro.com/date-converter.html

If you tell us what language are you trying to convert it in (programming language and \ or SQL dialect, such as MySQL, MSSQL etc) I can try and help converting the formula to an actual code.

EDIT:

Assuming $result contains your sql results;

$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;
}
2
  • The language i am using is postgresql, but i want to convert using php
    – Ash
    Aug 13, 2014 at 7:39
  • Thank you: $date['age'] = date("Y/m/d",$english_date);
    – Ash
    Aug 13, 2014 at 11:26
0

To make an approximate conversion, subtract 56 Years, 8 Months and 16 Days:

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

Again converting the strotime in to formated date:

$date['age'] = date("Y/m/d",$english_date);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.