2017-03-15 18 views

答えて

1

希望します。あなたはタイムスタンプを使用する必要が実行する操作については

Try this code snippet here

<?php 

date_default_timezone_set('Asia/Kolkata'); 

$DateTime=date('Y-m-d H:i:s'); 
$DateTime=date('H:i:s', strtotime($DateTime) - 3600); 
echo $DateTime; 
?> 
1

。日付文字列から数値を加算または減算することはできません。

使用これは役立つだろう。この

$timeBeforeAnHour = date('H:i:s',time() - 3600); 

のようなもの。

1

strtotimeが見つかりませんでした。

strtotimeは、あなたの日付のUNIXタイムスタンプを提供します。そのタイムスタンプから、その後、あなたがそうdate('H:i:s',strtotime($DateTime)-3600);

を行う必要があり、それは

<?php 
date_default_timezone_set('Asia/Kolkata'); 
$DateTime=date('Y-m-d H:i:s'); 
$DateTime=date('H:i:s',strtotime($DateTime) - 3600); 
echo $DateTime; 
?> 

でなければなりません

Referred from here

あなたの一時間を引くここでは、コードのみ使用しています eval link

+0

です現在の時刻を最初に取得するためにのみ機能します。ですから、日付を作成してタイムスタンプに変換する必要はないと思わないでください。代わりに、PHPで現在のタイムスタンプを直接取得することができます。 –

関連する問題