Menampilkan Text Berdasarkan Waktu Menggunakan JavaScript

Share:
Script untuk menampilkan Text Berdasarkan Waktu Menggunakan JavaScript 


<script language="JavaScript">
var myDate = new Date();
/* hour is before noon */
if ( myDate.getHours() < 12 ) 
{
    document.write(" Good Morning!");
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 12 && myDate.getHours() < 13 )
{
    document.write("Will come a Zuhur Time, let's pray!");
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 13 && myDate.getHours() < 16 )
{
    document.write("Good Afternoon!");
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 16 && myDate.getHours() < 17 )
{
    document.write("Good Afternoon!  Will come a Ashar Time, let's pray!");
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 17 && myDate.getHours() < 18 )
{
    document.write("Good Afternoon!");
}
else  /* Hour is from noon to 5pm (actually to 5:59 pm) */
if ( myDate.getHours() >= 18 && myDate.getHours() < 19 )
{
    document.write("Good Afternoon!  Will come a Magrib Time, let's pray!");
}
else  /* the hour is after 5pm, so it is between 6pm and midnight */
if ( myDate.getHours() >= 17 && myDate.getHours() <= 24 )
{
    document.write("Good Evening!
Importantly, limit on boarding activities until 10:00 PM
"); } else /* the hour is after 5pm, so it is between 6pm and midnight */ if ( myDate.getHours() > 4 && myDate.getHours() <= 5 ) { document.write("Good Morning!
Will come a Subuh Time, let's pray!
"); } else /* the hour is not between 0 and 24, so something is wrong */ { document.write("I'm not sure what time it is!"); } /* remove the following in your live script. It is for testing */ document.write("The hour is: "); </script>

Script untuk menampilkan jam load per second

  
<script type="text/javascript"> 
// 1 detik = 1000 
window.setTimeout("waktu()",1000); 
function waktu() {
var tanggal = new Date(); 
setTimeout("waktu()",1000); 
 document.getElementById("jamku").innerHTML = tanggal.getHours()+" : "+tanggal.getMinutes()+" : "+tanggal.getSeconds(); 
 } 
 </script> 
 

Jam

https://drive.google.com/file/d/0B8xVSaE8sQviRVhqUXhXTnZGeHM/view?usp=sharing

 

ads Bottom