Skip to content

Instantly share code, notes, and snippets.

@maykonmeier
Created June 4, 2015 14:25
Show Gist options
  • Save maykonmeier/499eaef0fb0d16871f66 to your computer and use it in GitHub Desktop.
Save maykonmeier/499eaef0fb0d16871f66 to your computer and use it in GitHub Desktop.
<?php
/* Working with dates
*
* 1. Everytime work with an object of type DateTime
* 2. Just use String into views or frontend using a format type
*
*/
$format = 'Y-m-d';
$date = DateTime::createFromFormat($format, '2009-02-15');
echo "Format: $format; " . $date->format('Y-m-d H:i:s') . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment