Last active
August 29, 2015 14:04
-
-
Save jpcercal/05001ccae00d5c6ae216 to your computer and use it in GitHub Desktop.
Create date from string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| setlocale(LC_ALL, NULL); | |
| setlocale(LC_ALL, 'pt_BR'); | |
| $time = "segunda-feira, 28 de julho de 2014 10h10min07s UTC-3"; | |
| $timeParts = explode(',', $time); | |
| $timeParsed = strptime( | |
| end($timeParts), | |
| '%d de %B de %Y %Hh%Mmin%Ss' | |
| ); | |
| $createdAt = date('Y-m-d h:i:s', mktime( | |
| $timeParsed['tm_hour'], | |
| $timeParsed['tm_min'], | |
| $timeParsed['tm_sec'], | |
| 1, | |
| $timeParsed['tm_yday'] + 1, | |
| $timeParsed['tm_year'] + 1900 | |
| )); | |
| echo $createdAt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment