Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtm1-strict.dtd">
- <!-- -------------------------------------------------------------------------------- -->
- <!-- Name: Ira Nelson -->
- <!-- Class: PHP and MySQL-140-400 -->
- <!-- Abstract: Assignment 9 -->
- <!-- -------------------------------------------------------------------------------- -->
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta charset="utf-8">
- <title>Are we in daylight savings? 2017</title>
- <link href="../../styles/common.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <h1>
- <?php
- $today = time();
- $currentTime = date( "g:i:s a");
- $currentDate = date( "F j, Y");
- $bolDaylightSavings = date("I");
- //decide if we are in daylight savings time and use appropreate date depending on answer
- if ($bolDaylightSavings == 1){
- $DLS_2017Date = mktime(2,0,0,11,05,2017);
- }
- else {
- $DLS_2017Date = mktime(2,0,0,3,12,2017);
- }
- $differenceInTime = $DLS_2017Date - $today;
- $function_results = CountDown_to_DaylightSavings($differenceInTime,$bolDaylightSavings);
- echo "The current time and date is $currentTime $currentDate</br >";
- echo "$function_results </br>";
- //went ahead and learned how php does funtions to make this a little easier hope that is okay.
- function CountDown_to_DaylightSavings($differenceInTime,$bolDaylightSavings) {
- $days = floor($differenceInTime / 86400);
- $remainder = (($differenceInTime / 86400) - $days) * $days;
- $hours = floor($remainder);
- $remainder = (((($differenceInTime / 86400) - $days) * $days) - $hours) * $hours;
- $minutes = floor($remainder);
- $remainder = (((((($differenceInTime / 86400) - $days) * $days) - $hours) * $hours) - $minutes) * $minutes;
- $seconds = floor($remainder);
- if ($bolDaylightSavings==1){
- $return = "We are currently in Daylight savings. There are $days days $hours hours $minutes minutes $seconds seconds until Daylight Savings Time ends.";
- }
- else {
- $return = "WE are currently not in Daylight savings. There are $days days $hours hours $minutes minutes $seconds seconds until Daylight Savings Time.";
- }
- return $return;
- }
- ?>
- </h1>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement