convert budha date time be for insert to mysql


it shoud be convert  before insert to mysql database in to feiild a(format date)

may be    '2011-12-11'  how can i convert it

budha calenda must minus 543 then it be come normal calendar
Who is Participating?
StingRaYConnect With a Mentor Commented:
Try this:

$budhadate = '111255';
preg_match('/^(\d{2})(\d{2})(\d{2})$/', $budhadate, $matches);
$budhayear = $matches[3]+2500;
$yyyy = $budhayear - 543;
$mm = $matches[2];
$dd = $matches[1];
$date = "{$yyyy}-{$mm}-{$dd}";

Open in new window

gnoonConnect With a Mentor Commented:
insert into table1(a) values( str_to_date( concat(left('111255',4),right('111255',2)+2500-543), '%d%m%Y') )

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.