Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. $date1 = $_REQUEST['date_1'];
  2. $date2 = $_REQUEST['date_2'];
  3.  
  4. //Remove the "/"s in the date, as this confuses the function which creates the DateTime object
  5. $date1 = str_replace("/", "-",$date1);
  6. $date2 = str_replace("/", "-",$date2);
  7.  
  8. // convert these date strings to the DateTime object for manipulation
  9. $date1 = date_create($date1);
  10. $date2 = date_create($date2);
  11.  
  12.  
  13. // Convert these DateTime objects to show the date in a differnt format as a string
  14. $date1 = date_format($date1, "Y-m-d");
  15. $date2 = date_format($date2, "Y-m-d");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement