Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP date time format for UK

Tags:

php

datetime

I have date variable i need to convert to a another type of date formats

//the date and time
$date="16-03-2014 00:16:01";

the format i want convert is like below

Sunday 16th of March 00:16:01

can someone please help me to do this.

like image 281
Salinda Bandara Avatar asked Apr 21 '26 17:04

Salinda Bandara


1 Answers

Use DateTime::createFromFormat to create a Datetime object, then output with specified format.

$date="16-03-2014 00:16:01";

$date = DateTime::createFromFormat('d-m-Y H:i:s', $date);
echo $date->format('l jS \of F H:i:s');
like image 85
xdazz Avatar answered Apr 23 '26 05:04

xdazz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!