Senin, 21 Agustus 2023

COUNT DOWN WAKTU

 Bersumber dari mari:

https://blog.rosihanari.net/membuat-countdown-menuju-tanggal-dan-waktu-tertentu-dengan-ajax/

date.php

<?php

//mengatur time zone untuk WIB.
date_default_timezone_set("Asia/Jakarta");
 
// mencari mktime untuk tanggal 1 Januari 2023 00:00:00 WIB
//$selisih1 =  mktime(0, 0, 0, 1, 1, 2011);
//$selisih1 =  mktime(0, 0, 0, 1, TGL, 2011);
 $selisih1 =  mktime(0, 0, 0, 8, 30, 2023);

// mencari mktime untuk current time
$selisih2 = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
 
// mencari selisih detik antara kedua waktu
$delta = $selisih1 - $selisih2;
 
// proses mencari jumlah hari
$a = floor($delta / 86400);
 
// proses mencari jumlah jam
$sisa = $delta % 86400;
$b  = floor($sisa / 3600);
 
// proses mencari jumlah menit
$sisa = $sisa % 3600;
$c = floor($sisa / 60);
 
// proses mencari jumlah detik
$sisa = $sisa % 60;
$d = floor($sisa / 1);
 
echo "Waktu saat ini: ".date("d-m-Y H:i:s")."<br>";
echo "Masih: ".$a." hari ".$b." jam ".$c." menit ".$d." detik lagi, 
menuju tahun baru 25 Agustus 2023";
 
?>


LALU PADA Index.php

<script type="text/javascript">
   
  function ajax() {
     if (window.XMLHttpRequest)
     {
       // untuk IE7+, Firefox, Chrome, Opera, Safari
       xmlhttp=new XMLHttpRequest();
     }
     else
     {
       // untuk IE6, IE5
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
   
     xmlhttp.onreadystatechange=function()
     {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
          // hasil pembacaan script date.php akan ditampilkan di komponen id="hasil"
          document.getElementById("ReloadThis").innerHTML = xmlhttp.responseText;
        }
     }
   
     // menjalankan script date.php secara asynchronous
     xmlhttp.open("GET","date.php", true);
     xmlhttp.send();
 
     // refresh time 1 detik (1000 ms)
     setTimeout("ajax()", 1000);
  }  
  </script>
  
</head>
<body onload="ajax()">

ATAU

<script type="text/javascript">
function Ajaxs(){
var $http,$self = arguments.callee;

if (window.XMLHttpRequest) {$http = new XMLHttpRequest();} 
else if (window.ActiveXObject) {
try {$http = new ActiveXObject('Msxml2.XMLHTTP');} 
catch(e) {$http = new ActiveXObject('Microsoft.XMLHTTP');}
}

if ($http) {
$http.onreadystatechange = function(){
if (/4|^complete$/.test($http.readyState)) {
document.getElementById('ReloadThis').innerHTML = $http.responseText;
setTimeout(function(){$self();}, 1000);
}
};
$http.open('GET', 'time.php' + '?' + new Date().getTime(), true);
$http.send(null);
}
}
</script>
<script type="text/javascript">setTimeout(function() {Ajaxs();}, 1000);</script>




Minggu, 20 Agustus 2023

CEK Tanggal EXPIRE

 


data bisa dari
20-Aug-2023
2023-08-20

<?php

$tgl=BAL($_POST["tanggal_selesai"]);
$startdate = $tgl;
$expire = strtotime($startdate. ' + 1 days');//1 hari kemudian Penanda exire

$today = strtotime("today midnight");


if($today >= $expire){

    echo "SUDAH HABIS MASA WAKTUNYA....";

} else {

    echo "LANJUTKAN>>>>Msh ada Waktu...";

}

?>

CODE LAIN:
if(!isset($_SESSION["cid"])){
die("<script>location.href='login.php';</script>");
}

<?php

$kode_tx="PND-9642";

$ada=cekKode($kode_tx,"PND");
echo $ada;


function cekKode($kode_tx,$init){
$cek=strstr($kode_tx,$init);
$ada=strlen($cek)+0;
return $ada;
}
?>



 <?php 
    $apples = array("Fuji", "McIntosh", "Red Delicious", "Gala", "Jonagold");
        
    foreach( $apples as $apple ) {
      echo "$apple is a type of apple <br/> <br/>";
    }
  ?>   
  
  <?php 
    $apples = ["Fuji", "McTntosh"]; 
    //This is how you can add values after initializing it.
    $apples[] = "Red Delicious";
    $apples[] = "Gala";
    $apples[] = "Jonagold";
        
    foreach( $apples as $apple ) {
      echo "$apple is a type of apple <br/> <br/>";
    }
 ?>   
  
   <?php 
    $CurrentVersions = [
      "php" => "7.4.5",
      "python" => "3.7",
      "java" => "14",
      "C#" => "8.0",
    ];
  ?>  
  
  <?php 
    $CurrentVersions["php"] = "7.4.5";
    $CurrentVersions["python"] = "3.7";
    $CurrentVersions["java"] = "14";
    $CurrentVersions["C#"] = "8.0";
  ?>  
   <?php 
    $CurrentVersions = [
      "php" => "7.4.5",
      "python" => "3.7",
      "java" => "14",
      "C#" => "8.0",
    ];

    echo $CurrentVersions["php"];

    foreach ($CurrentVersions as $lang => $version) {
      echo "<br/> <br/> latest Version of $lang is $version";
    }
  ?>  
 <?php
  $books = [
    "THIS EXPLAINS EVERYTHING" => [
      "author" => "John Brokman",
      "Release date" => "January 22,2013",
      "Price" => "$11.99"
    ],
    "YOU ARE STARDUST" => [
      "author" => "Elin kelsey",
      "Release date" => "September 12,2012",
      "Price" => "$13.29"
    ],
    "THINKING IN NUMBERS" => [
      "author" => "Daniel Tammet",
      "Release date" => "2012",
      "Price" => "$10.29"
    ]
  ];

  echo "You are Stardust is written by " . $books["YOU ARE STARDUST"]["author"];
  echo "<br/> Thinking in number was released on " .$books["THINKING IN NUMBERS"]["Release date"];
    ?>   
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  



Mencari Tanggal Terakhir Suatu Bulan

  $a_date = "$tahun-$bulan-01"; $lastdate= date('t',strtotime($a_date));//Y-m-t <?php require_once"koneksivar.php&...