Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3302318
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:50:21+00:00 2026-05-17T20:50:21+00:00

I have a table with data exactly like this: ID Heading Description Time Location

  • 0

I have a table with data exactly like this:

  ID  Heading       Description  Time       Location   Start_Date  End_Date
  63  Wed Serv      Small group  19:00:00   null       2010-10-13  null
  70  Fall Harvest  Calvary      null       Pepin, Wi  2010-10-30  null

My Calendar shows the events on the correct dates, but the time for both events is 7:00 pm and I can’t figure out why. For the one event the time is null but it’s still saying 7:00 pm on the calendar.

Take a look at the variable called $time

My script is this:

<?php

//if the current page is empty, set the date variable to the current time, else set the date variable to the currentpage
$date = empty($_GET['currentpage']) ? time() : strtotime($_GET['currentpage']);

//This puts the day, month, and year in separate variables
$day = date('d', $date);
$month = date('m', $date);
$year = date('y', $date);
$bigYear = date('Y', $date);
$first_day = mktime(0, 0, 0, $month, 1, $year);             //we need to generate the first day of the month
$month_name = date('F', $first_day);                        //get the current month's full spelling
$day_of_week = date('D', $first_day);                       //find out what day of the week the first day of the month falls on
$prevM = getDate(mktime(0, 0, 0, $month-1, 1, $year));      //gets an associative array of the previous month
$nextM = getDate(mktime(0, 0, 0, $month+1, 1, $year));      //gets an associative array of the next month                           
$prevMonth = "{$prevM['year']}-{$prevM['mon']}";            //gets the actual previous month's name. Subtracts the year from the month so you're not stuck in the current year.
$nextMonth = "{$nextM['year']}-{$nextM['mon']}";            //gets the actual next month's name. Subtracts the year from the month so you're not stuck in the current year.
$day_count = 1;                                             //counts the days up to 7 so we know when to start a new week
$day_num = 1;                                               //counter for the total number of days in the month
$dates = new dates();                                       //instantiate the dates object

//once we know what day of the week it falls on, we know how many blank days before it occur.
switch($day_of_week) {
    case "Sun": $blank = 0; break;
    case "Mon": $blank = 1; break;
    case "Tue": $blank = 2; break;
    case "Wed": $blank = 3; break;
    case "Thu": $blank = 4; break;
    case "Fri": $blank = 5; break;
    case "Sat": $blank = 6; break;
}

//then we need to determine how many days are in the month
$days_in_month = cal_days_in_month(0, $month, $year);

//Here we start building the table heads 
echo "<table>".PHP_EOL;
echo "\t\t\t\t<thead>".PHP_EOL;
echo "\t\t\t\t\t<tr>".PHP_EOL;
echo "\t\t\t\t\t\t<th colspan=2 class=\"noBorder\"><a href='{$_SERVER['PHP_SELF']}?currentpage=$prevMonth'>&laquo;</a></th>";
echo "\t\t\t\t\t\t<th colspan=3 class=\"noBorder\"><strong>$month_name"." "."$bigYear</strong></th>";
echo "\t\t\t\t\t\t<th colspan=2 class=\"noBorder\"><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextMonth'>&raquo;</a></th>";
echo "\t\t\t\t\t</tr>".PHP_EOL;
echo "\t\t\t\t\t<tr>".PHP_EOL;
echo "\t\t\t\t\t\t<th>Sun</th>".PHP_EOL;
echo "\t\t\t\t\t\t<th>Mon</th>".PHP_EOL;
echo "\t\t\t\t\t\t<th>Tue</th>".PHP_EOL;
echo "\t\t\t\t\t\t<th>Wed</th>".PHP_EOL;
echo "\t\t\t\t\t\t<th>Thu</th>".PHP_EOL;
echo "\t\t\t\t\t\t<th>Fri</th>".PHP_EOL;
echo "\t\t\t\t\t\t<th>Sat</th>".PHP_EOL;
echo "\t\t\t\t\t</tr>".PHP_EOL;
echo "\t\t\t\t</thead>".PHP_EOL;
echo "\t\t\t\t<tbody>".PHP_EOL;
echo "\t\t\t\t\t<tr>".PHP_EOL;

//first we take care of those blank days
while($blank > 0) 
{
    echo "\t\t\t\t\t\t<td>&nbsp;</td>".PHP_EOL;
    $blank = $blank-1;
    $day_count++;
}

//while we're not at the last day of the month...
while($day_num <= $days_in_month) 
{           
    //get the events from the table
    foreach($dates->getRows() as $results) 
{   
//parse the date field
$eventStartYear = substr($results['start_date'], 0, 4);
$eventStartMonth = substr($results['start_date'], 5, 2);
$eventStartDay = substr($results['start_date'], 8, 2);
$eventEndYear = substr($results['end_date'], 0, 4);
$eventEndMonth = substr($results['end_date'], 5, 2);
$eventEndDay = substr($results['end_date'], 8, 2);
$heading = $results['heading'];
$description = $results['description'];
$time = strftime("%l:%M %P", $results['time']);


//if the event fields are not null and the event day is equal to the day counter, and the event month and year are equal to the current month
// AND it is a multiple day event
if(!is_null($eventStartDay) && !is_null($eventStartMonth) && !is_null($bigYear) && !is_null($eventEndDay) && !is_null($eventEndMonth) && !is_null($eventEndYear) && $day_num == $eventStartDay && $month == $eventStartMonth && $bigYear == $eventStartYear)
{   
    $currentDay = $eventStartDay;

    //while the current day is less than or equal to the end day of the event
    while($currentDay <= $eventEndDay)
    {
        //echo "id = ".$id."<br />";
        //echo "time = ".$time."<br />";
        //echo "time2 = ".$time2."<br />";
        echo "\t\t\t\t\t\t<td><a href=\"displayEvent.php?id=$id\">$day_num<h4>".$heading."</h4><h5>".$time."</h5></a></td>".PHP_EOL;
        $currentDay++;
        $day_num++;
        $day_count++;
    }
 }

 if(!is_null($eventStartDay) && !is_null($eventStartMonth) && !is_null($bigYear) && $day_num == $eventStartDay && $month == $eventStartMonth && $bigYear == $eventStartYear)
 {
    //echo "id = ".$id."<br />";
    //echo "time = ".$time."<br />";
    //echo "time2 = ".$time2."<br />";
    echo "\t\t\t\t\t\t<td><a href=\"displayEvent.php?id=$id\">$day_num<h4>".$heading."</h4><h5>".$time."</h5></a></td>".PHP_EOL;
    $day_num++;
    $day_count++;

 }

 //make sure we start a new row every week
 if($day_count > 7) 
 {
     echo "\t\t\t\t\t</tr>".PHP_EOL;
     echo "\t\t\t\t\t<tr>".PHP_EOL;
     $day_count = 1;
 }

}

                        //print days that don't have events
                        echo "\t\t\t\t\t\t<td><a href=\"noEvent.php\">$day_num</a></td>".PHP_EOL;
                        $day_count++;
                        $day_num++;

                        //make sure we start a new row every week
                        if($day_count > 7) 
                        {
                           echo "\t\t\t\t\t</tr>".PHP_EOL;
                           echo "\t\t\t\t\t<tr>".PHP_EOL;
                           $day_count = 1;
                        }
                    }

                    //finish the table with some blanks if needed
                    while($day_count > 1 && $day_count <= 7) {
                        echo "\t\t\t\t\t\t<td>&nbsp;</td>".PHP_EOL;
                        $day_count++;
                    }

                    echo "\t\t\t\t\t</tr>".PHP_EOL;
                    echo "\t\t\t\t</tbody>".PHP_EOL;
                    echo "\t\t\t</table>".PHP_EOL;

                ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:50:22+00:00Added an answer on May 17, 2026 at 8:50 pm

    The problem is with the $time = strftime("%l:%M %P", $results['time']); line. If you pass strftime a null value, it will default to 12:00am UTC, which in your timezone will be 7:00pm. This is why both records show up as 7:00pm. You should add some logic to set a default time to show up for records with unspecified times.

    For example:

    $time = $results['time'] != null ? strftime("%l:%M %P", $results['time']) : "";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of time-series data of which I need to find all
I have a table like this: id number otherfields ------------------------------------------- 664 48 aaa 665
I have a table of the form CREATE TABLE data { pk INT PRIMARY
I have table rows of data in html being filled from a CGI application.
I have a table of data, and I allow people to add meta data
I have a table of data sorted by date, from which a user can
I have the following table and data in SQL Server 2005: create table LogEntries
I have a table of paged data, along with a dynamically created pager (server-side
I have a table that has redundant data and I'm trying to identify all
I have a table which holds flight schedule data. Every schedule have an effective_from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.