PHP display date as month name and date [duplicate] - php

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 5 years ago.
I am getting current date using the function date("Y-m-d").
I want to display date 2017-09-12 as sep 12

You can present it as ("M j"). Here is a test version.

this will do: date_format($date,"M/d");

Here is your date..
$myDate = "2017-09-12";
Then you have to convert your date with Date PHP function
$date = date("M d",mktime("0 0 0 ".$myDate));
echo $date will print Sep 12
d is Day of the month, 2 digits with leading zeros
M is a short textual representation of a month, three letters

Related

Hot to convert string into date in php [duplicate]

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

Change date format with month name to dd/mm/YYYY [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 6 years ago.
I have a string with a date in this format: April 16, 2017 23:59, I would like to write a function to change it so that it's in this format: dd/mm/YYYY eg 16/04/2017
I tried to use the date function but couldn't get it to work. Does anyone know how I can do this in PHP?
$date = 'April 16, 2017 23:59';
echo date("d/m/Y",strtotime($date));

Php convert a date to string character [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 6 years ago.
I have searched but I could not find out how to convert a date from a character string. For example string date is 18-08-2016 I want to convert 18 August 2016 How can I do?
$input = '18-08-2016';
echo strftime('%d %B %Y',strtotime($input));// 18 August 2016
Use this resource to format the output to your liking.

Specify my date PHP [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
Closed 6 years ago.
I have attribut date_input in my database
etat_input : 2016-06-06
I would convert my date on format:
since : 06 june 2016
I try with :
<?php echo $var['etat_input'];?>
but no result.
First convert date_input to timestamp:
$timestamp = strtotime($var['etat_input']);
Now feed that $timestamp to date with proper format:
date('d M Y', $timestamp);
PHP Sandbox example

php date month from full name to short name [duplicate]

This question already has answers here:
Convert one date format into another in PHP
(17 answers)
php how to change date to this format [duplicate]
Closed 8 years ago.
I have this php script
date('dS F Y', strtotime($dateVariable))
The result is this:
01st September 2014
but I need the result as this: 01st Sep 2014
in other words, I need not the full name of the month. is that possible please?
date('dS M Y', strtotime($dateVariable))
Try as below
date('dS M Y', strtotime($dateVariable))
You can do it directly with the date function, using the 'M' mode.
http://php.net/manual/en/function.date.php
Alternatively, check out the function JDMonthName -- using mode 2 you can get the abbreviated month name.
http://php.net/manual/en/function.jdmonthname.php
Alternatively, check out the strftime function (much like printf) for formatting your date. The %b format gives the abbreviated month name.
http://php.net/manual/en/function.strftime.php

Categories