Virajsinh

DateFormat_PhP

Feb 24th, 2020
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2. $date = DateTime::createFromFormat('d/m/Y', $_REQUEST['dob']);
  3. $date->format('Y-m-d')
  4.  
  5. //YYYY-MM-DD HH:MM:SS MySQL Date Type
  6. //date("Y-m-d H:i:s"); MySQL date Type to PhP
  7.  
  8. $newDateString = date_format(date_create_from_format('Y-m-d', $dateString), 'd-m-Y');
  9. ?>
  10.  
  11. <?php
  12.     $source = '2012-07-31';
  13.     $date = new DateTime($source);
  14.     echo $date->format('d.m.Y'); // 31.07.2012
  15.     echo $date->format('d-m-Y'); // 31-07-2012
  16. ?>
  17.  
  18. <?php if(isset($categorydata)){ foreach($categorydata as $crow){ ?>
  19.     <option <?php if($crow['id'] == $blogdata['category_id']){ echo "selected"; } ?> value="<?=$crow['id'];?>">
  20.     <?=$crow['name'];?>
  21.     </option>
  22. <?php } } ?>
  23.  
  24. https://www.youtube.com/VirajsinhNakum?sub_confirmation=1
Add Comment
Please, Sign In to add comment