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 を VarChar に変換する方法
例
どのように SQL 日時 (たとえば08/14/2012 1:05:18 PM) を mysql の方法 (つまり Ymd H:i:s ) に変換しますか?
08/14/2012 1:05:18 PM
変換したい場所によって異なります。
SQL を直接変換するには:
convert(varchar(23), getdate(), 121)
date関数とstrtotime関数を使用する PHP :
date("Y-m-d H:i:s ", strtotime("08/14/2012 1:05:18 PM"));
$var = "08/14/2012 1:05:18 PM"; echo date('Y-m-d H:i:s', strtotime($var));
PHP で日付の形式を次のように変更します。
<? $date = date("Y-m-d H:i:s ", strtotime("08/14/2012 1:05:18 PM")); echo $date; ?>