0

重複の可能性:
PHP の秘密の時刻形式

私はmysqlデータベースからstart_timeフィールド値を取得しています2012-08-14 21:30:00

2012-08-14T09:30 のような php 形式に変換したいのですが、何か方法はありますか

これはphpで?

4

2 に答える 2

2

strtotime()を使用する

$date = strtotime('2012-08-14 21:30:00');
echo date('Y-m-d\Th:i',$date);
于 2012-08-18T07:53:59.340 に答える
0

必要な日付と時刻の形式については、この例を参照してください。

$date=date("Y-m-d H:i:s");//get the current date
$d=strtotime($date);//convert in strtotime
echo $final_date=date("Y-m-d\Th:i:s",$d);//in the first argument of date ,put the format whatever you want,but be sure to convert it in strtotime first.
于 2012-08-18T08:06:06.170 に答える