How to display date from string (format) [duplicate] - php

This question already has answers here:
Convert a date format in PHP [duplicate]
(18 answers)
Closed 7 years ago.
I have date (string):
2015-11-13T15:43:37+01:00
And I want to display this as "Y-m-d H:i:s" format. How to do it?

You can format your date with "date_format()"
http://php.net/manual/en/function.date-format.php

Related

How to Change Date Format yyyy-mm-dd to dd-mm-yyyy [duplicate]

This question already has answers here:
MySQL date format DD/MM/YYYY select query?
(9 answers)
Convert a date format in PHP [duplicate]
(18 answers)
Closed 3 years ago.
When I display date from phpMyadmin to webpage with this code.
date format is showing y-m-d
and how to change this in d-m-y
<?php echo $row['dob']; ?>
You can use DATE_FORMAT
SELECT DATE_FORMAT(column_name, '%d/%m/%Y') FROM tablename

I want to save different date format tha saved in yii2 datepicker [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Format date dd/mm/yyyy to yyyy-mm-dd PHP [duplicate]
(7 answers)
PHP convert date format dd/mm/yyyy => yyyy-mm-dd [duplicate]
(5 answers)
How to convert MM/DD/YYYY to YYYY-MM-DD?
(8 answers)
Yii2 View DateTime Format (d-m-Y H:i:s) But When Save/update in DB Change format to Y-m-d H:i:s
(5 answers)
Closed 5 years ago.
I am using yii2 datepicker in my project.
I want to show selected date as dd/mm/YYYY but want to save date in model as YYYY-mm-dd.
How can I do so?
You can format datepicker in Controller,and then render the view.
Controller:
$model->birth_date=Yii::$app->formatter->asDate($model->birth_date, "dd/mm/yyyy");
Then Store like this:
$model->birth_date=Yii::$app->formatter->asDate($model->birth_date, "yyyy-mm-dd");

Change type of date in html table - php mysql [duplicate]

This question already has answers here:
Convert from MySQL datetime to another format with PHP
(18 answers)
Convert one date format into another in PHP
(17 answers)
Closed 6 years ago.
I need some help with converting the date to dd/mm/YYYY.
I have this code to display my date in a html table from a mysql database
echo "<td>".$zeile['datumFahrt']."</td>";
Can I convert it in this line so the format will be dd/mm/YYYY instead of YYYY/mm/dd?
Sure you can, first you need to convert it to timestamp and then format it:
date("d/m/Y", strtotime($zeile['datumFahrt']))

PHP Convert Date/Time format from 'd/m/Y H:i:s' to 'H:i:s'? [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 7 years ago.
I have a timestamp column in my database with dates and times formatted like '24/06/2015 14:30', but I need to convert it to just '14:30'. I've tried everything please help.
Very easy to use, just pass in argument and format: http://php.net/manual/en/class.datetime.php

php - date format ISO 8601 [duplicate]

This question already has answers here:
How do I convert an ISO8601 date to another format in PHP?
(2 answers)
Closed 9 years ago.
I have encountered this date format:
2013-03-12T09:16:12.1550656+01:00
from what I have found in net this is ISO 8601 (am I correct?).
How can I convert this this date format using php?
I can generate it easily using date('c'), but I need convert this type of date:
20130422122037 - (YYYYMMDDHHMMSS)
Try this:
$date = new DateTime('20130422122037');
var_dump($date->format('c'));

Categories