I have the following date: 2010-04-19 18:31:27. I would like to convert this date to the dd/mm/yyyy format.
You can use a regular expression or some manual string fiddling, but I think I prefer:
date("d/m/Y", strtotime($str));
Answer:
<?php
$test1='2010-04-19 18:31:27';
echo date('d/m/Y',strtotime($test1));
?>
try this
Answer:
If your date is in the format of a string use the explode function
array explode ( string $delimiter , string $string [, int $limit ] )
//In the case of your code
$length = strrpos($oldDate," ");
$newDate = explode( "-" , substr($oldDate,$length));
$output = $newDate[2]."/".$newDate[1]."/".$newDate[0];
Hope the above works now
Answer:
There is also the DateTime
object if you want to go that way: http://www.php.net/manual/en/datetime.construct.php
Answer:
Try this:
$old_date = Date_create("2010-04-19 18:31:27");
$new_date = Date_format($old_date, "d/m/Y");
Answer:
$source = 'your varible name';
$date = new DateTime($source);
$_REQUEST["date"] = $date->format('d-m-Y');
echo $_REQUEST["date"];