Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次の文字列からDateTimeを作成しようとしています。
2012-02-16 00:45:54.441899
私はこのフォーマットで試しましたが、成功しませんでした:
Ymd H:i:s。*
私に何ができる?ドットの後の部分は気にしません。
フォーマットのマイクロ秒部分を忘れました:
$s = '2012-02-16 00:45:54.441899'; $d = DateTime::createFromFormat('Y-m-d H:i:s.u', $s);//format looks like your string echo $d->format('Ymd');//output format can be whatever you like