Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert to date format dd/mm/yyyy

Tags:

date

php

format

I have the following date: 2010-04-19 18:31:27. I would like to convert this date to the dd/mm/yyyy format.

like image 792
Rui Gonçalves Avatar asked Apr 19 '10 21:04

Rui Gonçalves


People also ask

How do I change the date format in Excel to DD MMM YYYY?

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.

How do I change date format to date?

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.


2 Answers

You can use a regular expression or some manual string fiddling, but I think I prefer:

date("d/m/Y", strtotime($str)); 
like image 192
Michael Mrozek Avatar answered Oct 09 '22 10:10

Michael Mrozek


<?php $test1='2010-04-19 18:31:27'; echo date('d/m/Y',strtotime($test1)); ?> 

try this

like image 26
Murali Krishna kilari Avatar answered Oct 09 '22 09:10

Murali Krishna kilari