Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.49 KB | None | 0 0
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtm1-strict.dtd">
  4.  
  5.         <!-- -------------------------------------------------------------------------------- -->
  6.         <!-- Name: Ira Nelson                                                                 -->
  7.         <!-- Class: PHP and MySQL-140-400                                                     -->
  8.         <!-- Abstract: Assignment 9                                                           -->
  9.         <!-- -------------------------------------------------------------------------------- -->
  10.  
  11. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  12.  
  13.     <head>
  14.  
  15.         <meta charset="utf-8">
  16.        
  17.         <title>Are we in daylight savings? 2017</title>
  18.         <link href="../../styles/common.css" rel="stylesheet" type="text/css" />
  19.     </head>
  20.    
  21.     <body>
  22.  
  23.     <h1>
  24.             <?php
  25.         $today = time();
  26.         $currentTime = date( "g:i:s a");
  27.         $currentDate = date( "F j, Y");
  28.         $bolDaylightSavings = date("I");
  29.        
  30.        
  31.         //decide if we are in daylight savings time and use appropreate date depending on answer
  32.         if ($bolDaylightSavings == 1){
  33.             $DLS_2017Date = mktime(2,0,0,11,05,2017);
  34.         }
  35.         else {
  36.             $DLS_2017Date = mktime(2,0,0,3,12,2017);
  37.         }
  38.        
  39.         $differenceInTime = $DLS_2017Date - $today;
  40.         $function_results = CountDown_to_DaylightSavings($differenceInTime,$bolDaylightSavings);
  41.        
  42.        
  43.         echo "The current time and date is $currentTime $currentDate</br >";
  44.        
  45.         echo "$function_results </br>";
  46.        
  47.        
  48.        
  49.        
  50.         //went ahead and learned how php does funtions to make this a little easier hope that is okay.
  51.     function CountDown_to_DaylightSavings($differenceInTime,$bolDaylightSavings) {
  52.        
  53.        
  54.         $days = floor($differenceInTime / 86400);
  55.         $remainder = (($differenceInTime / 86400) - $days) * $days;
  56.         $hours = floor($remainder);
  57.         $remainder = (((($differenceInTime / 86400) - $days) * $days) - $hours) * $hours;
  58.         $minutes = floor($remainder);
  59.         $remainder = (((((($differenceInTime / 86400) - $days) * $days) - $hours) * $hours) - $minutes) * $minutes;
  60.         $seconds = floor($remainder);
  61.          
  62.          if ($bolDaylightSavings==1){
  63.         $return = "We are currently in Daylight savings. There are $days days $hours hours $minutes minutes $seconds seconds until Daylight Savings Time ends.";
  64.          }
  65.          else {
  66.              $return = "WE are currently not in Daylight savings. There are $days days $hours hours $minutes minutes $seconds seconds until Daylight Savings Time.";
  67.          }
  68.        
  69.         return $return;
  70.     }
  71.            
  72.         ?>
  73.     </h1>
  74.  
  75.     </body>
  76.    
  77. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement