-1

how to remove the separator from the date input I have below

$date=$_POST["input"];
$new = date_format($date,"Y M D");
hmofrad
  • 1,784
  • 2
  • 22
  • 28

3 Answers3

1

Try this one

<?php 

$date=$_POST["input"];

// prints the current time in date format  
echo date("Y M D", strtotime($date))."\n"; 

?>
Suresh Kumar
  • 513
  • 1
  • 5
  • 15
0

Use date_create() to change datatype from string to date

$date=date_create($_POST["input"];);
echo date_format($date,"Y M D");
Mannu saraswat
  • 1,061
  • 8
  • 15
0

Use strtotime function convert date string into unix timestamp. Then convert into required format.

<?php 
    echo date("Y M D", strtotime($_POST["input"])); 
?>
Gowri
  • 1,832
  • 3
  • 29
  • 53