Advertisement
arijulianto

PHP Olah Waktu (strtotime)

Jan 6th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2. // Waktu sekarang
  3. $now = date('Y-m-d H:i:s');
  4. // Waktu (1000 jam ke belakang)
  5. $min1000 = date('Y-m-d H:i:s', strtotime('-1000 hour'));
  6. // Waktu (1000 jam ke depan)
  7. $plus1000 = date('Y-m-d H:i:s', strtotime('+1000 hour'));
  8.  
  9. // contoh 1: query (1000 jam sebelum sekarang sampai sekarang)
  10. $db->query("SELECT * from tabel_data where tanggal between '$min1000' AND '$now'");
  11.  
  12. // contoh 2: query (sekarang sampai 1000 jam kedepan)
  13. $db->query("SELECT * from tabel_data where tanggal between '$now' AND '$plus1000'");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement