I have the following date: 2010-04-19 18:31:27. I would like to convert this date to the dd/mm/yyyy format.
First, pick the cells that contain dates, then right-click and select Format Cells. Select Custom in the Number Tab, then type 'dd-mmm-yyyy' in the Type text box, then click okay. It will format the dates you specify.
Convert text dates by using the DATEVALUE function Select a blank cell and verify that its number format is General. Click the cell that contains the text-formatted date that you want to convert. Press ENTER, and the DATEVALUE function returns the serial number of the date that is represented by the text date.
You can use a regular expression or some manual string fiddling, but I think I prefer:
date("d/m/Y", strtotime($str));
<?php $test1='2010-04-19 18:31:27'; echo date('d/m/Y',strtotime($test1)); ?>
try this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With