This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 6 years ago.
After searching still problems with string replace
My $date looks like
Sat, 11 Feb 2017 11:33:38 +0100
I need only the date part (YYYY-MM-DD):
2017-02-11
Please can somebody help.
Thank you!
Best regards,
Roman
Use
date("Y-m-d", strtotime($date));
$date is var name that contain like Sat, 11 Feb 2017 11:33:38 +0100
use
date("Y-M-D", strtotime($date));
Related
This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 3 years ago.
I am getting data in my php variable from database:
var_dump("The schedule is: ".$my_Schedule);
I am getting this output:
string(37) "Reviews created : 2019-10-19 03:47:57"
Now I want to use this data to show something like:
// My Desired Result
Oct 01, 2019
I don't want time here.
I am doing it like this:
<p><?=date('Y-m-d',$my_Schedule);?></p>
This is not working for me.
Kindly suggest what I am doing wrong.
Any idea or suggestion would be helpful.
Thank You.
Please use following code
echo date('M d,Y',strtotime('2019-10-19 03:47:57'));
You can use like this:
$date = date('M d, Y', strtotime('2019-10-19 03:47:57'));
echo $date;
// output Oct 19, 2019
This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 4 years ago.
I have a string
date = 25 aug 18
is there any way to convert this into date time format,
date = 25 August 2018
Use:
echo date('d F Y', strtotime("25 aug 2018")). "\n";
output: https://3v4l.org/2T9NF
refer:
http://php.net/manual/en/function.strtotime.php
http://php.net/manual/en/function.date.php
This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 5 years ago.
Need Solution For Providing Date And Time.
Have a look to DateTime::createFromFormat:
$dt = DateTime::createFromFormat('d M Y h:i:s O', '01 Feb 2018 01:01:12 +0530');
echo $dt->format("Y-m-d H:i:s");
try this
$date = "Thu, 01 Feb 2018 01:01:12 +0530";
echo date("Y-m-d H:i:s",strtotime($date));
This question already has answers here:
How to convert date to timestamp in PHP?
(22 answers)
Closed 9 years ago.
How can I convert a date in the following format to a unix timestamp?
Thu, 26 Dec 2013 17:53:05 +0100
Thanks, Regards !
Use strtotime:
For example,
echo(strtotime("Thu, 26 Dec 2013 17:53:05 +0100"));
will output
1388076785
strtotime will give you a unix timestamp from a date string, provided it's in a valid format.
Verbose version (oop / robust):
$dateString = 'Thu, 26 Dec 2013 17:53:05 +0100';
$date = DateTime::createFromFormat(
DateTime::RSS,
$dateString,
new DateTimeZone('UTC')
);
echo $date->getTimestamp().PHP_EOL // 1388076785
.$date->format('r').PHP_EOL; // Thu, 26 Dec 2013 17:53:05 +0100
: demo
This question already has answers here:
convert strtotime to date time format in php
(5 answers)
Closed 9 years ago.
This is my String Tue, 20 Aug 2013 10:45:05
and i want to this string in Date Format Like this :
2013-08-20.
Guys Please help.
Thanks
Something like this:
echo date('Y-m-d', strtotime('Tue, 20 Aug 2013 10:45:05'));
Try this,
$d=date('Y-m-d',strtotime('Tue, 20 Aug 2013 10:45:05'));
echo $d;