This question already has answers here:
How do I convert an ISO8601 date to another format in PHP?
(2 answers)
Closed 8 years ago.
There is a string:
$time = "2013-07-10T21:00:00.000";
How to convert it to the format "2013-07-10 21:00:00"?
$time = strtotime("2013-07-10T21:00:00.000");
return strftime("%Y-%m-%d %H:%M:%S", $time);
$date = new \DateTime($time);
$date->format('Y-m-d H:i:s');
$time = "2013-07-10T21:00:00.000";
echo date("Y-i-d H:m:s",strtotime($time));
Related
This question already has answers here:
Formatting an SQL timestamp with PHP
(6 answers)
Convert one date format into another in PHP
(17 answers)
Closed 6 years ago.
I have a database timestamp with this format 2016-06-01 11:46:00 and I would like to convert and echo it to this format Wed. 01-06-2016.I tried a lot but no desirable results..Any ideas?
Thanks a lot, it worked!
If I want the difference between today and the past date in days or weeks I think I use date_diff.How exactly?
Simply use date and strtotime:
$time = '2016-06-01 11:46:00';
echo date("D. d-m-Y", strtotime($time)); //Wed. 01-06-2016
Updates:
$grk = array("Tet"); // complete the rest of the array
$eng = array("Wed"); // complete the rest of the array
$time = '2016-06-01 11:46:00';
$date = date("D. d-m-Y", strtotime($time));
echo str_replace($eng, $grk, $date);
$time = '2016-06-01 11:46:00';
echo date("D. d-m-Y", strtotime($time)); //Wed. 01-06-2016
This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 7 years ago.
Good afternoon!
I have a simple question.
I have a date format in PHP
$ originalDate = "22/08/2015 20:36";
How to translate
2015-08-20 00:00:00
?
Try this:
<?php
$originalDate = "22/08/2015 20:36";
$date = DateTime::createFromFormat('d/m/Y H:i', $originalDate);
echo $date->format('Y-m-d H:i:s');
?>
This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 7 years ago.
I have a function to convert EDT to system time,
function edttogmt($date){
$date = str_replace('$','', $date);
$date = str_replace('EDT','', $date);
$date = date('Y-m-d H:i:s',strtotime($date));
return $date;
}
And my date is like $date = '$07/23/2015 12:38:23 PM EDT';
Is it possible to convert this to my server time.The above function creates wrong
You can exactly describe the input format to receive DateTime object
$date = DateTime::createFromFormat('$m/d/Y h:i:s A e', '$07/23/2015 12:38:23 PM EDT');
echo $date->format('Y-m-d H:i:s'); // 2015-07-23 12:38:23
This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 8 years ago.
based on this code :
$tarikh = mysql_real_escape_string($_POST['tarikh']);
$tarikh = date('Y-m-d', strtotime($_POST['tarikh']));
can someone show me to convert the format from Y-m-d to d-m-Y format ? thanks
try this
$tarikh = mysql_real_escape_string($_POST['tarikh']);
$myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh);
$newDateString = $myDateTime->format('d-m-Y');
This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 6 years ago.
I have a string mm-dd-yyyy which i get from a form, which i want to store it in the database of the data-type DATE (yyyy-mm-dd).
How do i format the string and save it in the database ?
$new_format = date("Y-m-d", strtotime('04-28-2012'));
or
$date = new DateTime('04-28-2012');
$new_format = $date->format('Y-m-d');
or in PHP 5.5+
$new_format = (new DateTime('04-28-2012'))->format('Y-m-d');
Try
$date = DateTime::createFromFormat("m-d-Y", '02-15-2012');
echo $date->format('Y-m-d H:i:s') , "\n";
Output
2012-02-15 23:54:52