Nurrohman110

Comparasion Date & count date

Aug 3rd, 2020 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. comparasion date
  2.  
  3. <?php
  4. $paymentDate = date('Y-m-d');
  5. $paymentDate=date('Y-m-d', strtotime($paymentDate));
  6. $contractDateBegin = date('Y-m-d', strtotime("2020-08-03"));
  7. $contractDateEnd = date('Y-m-d', strtotime("2020-08-03"));
  8.  
  9. if (($paymentDate >= $contractDateBegin) && ($paymentDate <= $contractDateEnd)){
  10. echo "is between";
  11. }else{
  12. echo "NO GO!";
  13. }
  14. ?>
  15.  
  16. // count date
  17. <?php
  18. $startTimeStamp = strtotime("2020-08-01");
  19. $endTimeStamp = strtotime("2020-08-01");
  20.  
  21. $timeDiff = abs($endTimeStamp - $startTimeStamp);
  22.  
  23. $numberDays = $timeDiff/86400; // 86400 seconds in one day
  24.  
  25. // and you might want to convert to integer
  26. $numberDays = intval($numberDays);
  27. if($numberDays > 0){
  28. echo 'lebih dari 0';
  29. }else{
  30. echo $numberDays.' masih 0';
  31. }
  32. ?>
  33.  
  34.  
Add Comment
Please, Sign In to add comment