J'ai essayé beaucoup de façons de faire, mais le format de chaîne pour mois me fait un gros problème. Toute suggestion, conseil ou code réalisé sera utile.Comment convertir les fichiers date 14/Dec/2012 14:53:34 à timestamp en php?
0
A
Répondre
1
Avez-vous essayé strtotime()? Documentation complète ici: http://php.net/manual/en/function.strtotime.php
6
strtotime(); ne semble pas fonctionner pour ce format.
Jetez un oeil à l'aide d'un objet DateTime en utilisant votre format personnalisé: http://us3.php.net/manual/en/datetime.createfromformat.php
Ensuite, vous pouvez le sortir comme vous le souhaitez, y compris l'horodatage via le format $ dateObject-> ('U');
donc quelque chose comme:
$oDt = DateTime::createFromFormat('d/M/Y H:i:s', '14/Dec/2012 14:53:34');
echo $oDt->format('U'); // 1355518414
devrait fonctionner.
Vérifiez en arrière:
echo date('c', 1355518414); //2012-12-14T14:53:34-06:00
1
Si vous utilisez PHP 5.3+ alors vous pouvez obtenir un DateTime
en utilisant DateTime::createFromFormat('j/M/Y H:i:s',$string)
vous pouvez utiliser getTimestamp()
sur l'objet DateTime
retourné pour obtenir l'horodatage.
Questions connexes
- 1. convertir datetime en timestamp php
- 2. convertir unix timestamp php
- 3. Convertir la date RFC 1123 en timestamp en PHP
- 4. Convertir Int Timestamp à Date/Heure
- 5. Comment convertir les photos timestamp en Qt?
- 6. Convertir la date en timestamp UNIX
- 7. Bash convertir la date en timestamp
- 8. Convertir une date de chaîne en timestamp
- 9. Convertir Timestamp en R
- 10. Convertir en mysql TIMESTAMP
- 11. Comment convertir en format Timestamp en Java?
- 12. Comment convertir DATE UNIX TIMESTAMP en script shell sur MacOS
- 13. Comment convertir une date humaine en timestamp unix dans Mysql?
- 14. Comment convertir la date Android en TimeStamp Linux?
- 15. PHP date - String to Timestamp
- 16. mysql comment convertir varchar (10) à TIMESTAMP?
- 17. Convertir cette chaîne en timestamp PHP
- 18. timestamp (int) à date (string) dans php
- 19. Date Convertir en php
- 20. Comment convertir datetime en timestamp époque
- 21. Comment convertir un horodatage en timestamp unix en php?
- 22. Convertir timestamp MYSQL à time_t
- 23. Comment convertir le now() en timestamp
- 24. Convertir timestamp en alphanum
- 25. Convertir UTC en Unix Timestamp
- 26. convertir timestamp unix à GMT dans Cakephp ou php
- 27. timestamp to date problème de conversion en php
- 28. Comment convertir un TimeStamp au format Date approprié?
- 29. convertir chaîne à date type en php
- 30. Convertir jours timestamp unix
qu'avez-vous essayé? – Cfreak
D'où récupérez-vous les données? Est-ce un résultat SQL? – luchosrock