Say it I get a date from MySQL table like 2012-03-31
.
I pass this date to a Java application. So Java needs that date as 2012, 02, 31
.
Firstly I explode date, get second element, subtract one from the month value. Then I implode three elements and create new date string.
public function convertToJavaDate($mysqlDate) {
$pieces = explode("-",$mysqlDate);
return $pieces[0].", ".($pieces[1]-1).", ".$pieces[2];
}
Is there a quicker or smarter way to do this ?