Jump to content

Wrong Date Displayed


amin1982

Recommended Posts

Hey All,

 

As of this morning our gallery has started to show the incorrect dates. Please go to: http://www.nightlifeguestlist.com/c...n/74/Carbon.htm you will see the first date is Fri, 29 October 10 this should be Sat, 30 October 10.

 

In the database the date is in putted as 2010-10-30.

 

The dates from Fri, 29 October 10 to Fri, 2 April 10 are all incorrect. These happen to be all BST times. While the dates for GMT are OK. The clocks here in the UK are now GMT and not BST. Has this anything to do with it?

 

The code used is as follows:

 

<?
$location = false;
if(isset($_GET['l'])){
    $location = $_GET['l'];
}
$venue = false;
if(isset($_GET['v'])){
    $venue = $_GET['v'];
}
$event = false;
if(isset($_GET['e'])){
    $event = $_GET['e'];
}
$page = 0;
if(isset($_GET['p'])){
    $page = $_GET['p'];
    $page--;
}
$query_events = "";

if(!$location){
    $query_events = "SELECT ec_venues.location FROM ec_venues GROUP BY ec_venues.location";
} else if($location && !$venue && !$event){
    $query_events = "SELECT ec_venues.venue_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_venues.venue_id, ec_events.event_id,ec_venues.location FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_events.event_date IS NOT NULL  AND ec_venues.location='".$location."' ORDER BY UNIX_TIMESTAMP(ec_events.event_date) DESC LIMIT 0,1";
} else if($venue && !$event){
    $query_events = "SELECT UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_venues.venue_name, ec_venues.venue_id, ec_events.event_id, ec_events.event_name,ec_venues.location FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_venues.venue_id=".$venue." ORDER BY UNIX_TIMESTAMP(ec_events.event_date) DESC";
} else if($venue && $event){
    $query_events = "SELECT ec_venues.venue_name, ec_events.event_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_events.image_folder, ec_venues.images_per_page,ec_venues.location FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_events.event_id=".$event." AND ec_venues.venue_id=".$venue."";
}
mysql_select_db($database_nightlife2 , $nightlife2 );
//    $query_events = "SELECT ec_venues.venue_name, ec_events.event_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_events.image_folder, ec_venues.images_per_page FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_events.event_id=".$event." AND ec_venues.venue_id=".$venue."";
//echo $query_events;
$events = mysql_query($query_events, $nightlife2 ) or die(mysql_error());
$row_events = mysql_fetch_assoc($events);
$totalRows_events = mysql_num_rows($events);
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?=(!$location?"Elite Parties Photos":"Nightlife Guestlist @ ".$location." Club - ".$row_events['venue_name'])?></title>
<link href="http://www.nightlifeguestlist.com/wp-content/themes/NLGL/style.css" rel="stylesheet" type="text/css" />

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="http://www.nightlifeguestlist.com/wp-content/themes/NLGL/IE-6.css" />
<![endif]-->
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="http://www.nightlifeguestlist.com/wp-content/themes/NLGL/IE-8.css" />
<![endif]-->
<? if($_SERVER['HTTP_HOST']=="elite"){?>
<BASE HREF="http://elite/">
<? } else { ?>
<BASE HREF="http://www.nightlifeguestlist.com/">
<? } ?>

<SCRIPT language="JavaScript" src="/mircoFinestra.js"></script>

<script src="/AC_RunActiveContent.js" type="text/javascript"></script> 


</style>
</head>

<body>

<div class="wrapper">

<div id="head">
<div id="header">





</div>
<!-- nav -->        
<div id="nav">
<div id="nav-area">
<ul>
<li class='page_item current_page_item'><a href='http://www.nightlifeguestlist.com' title='Home'>Home</a></li><li class="page_item page-item-3"><a href="http://www.nightlifeguestlist.com/guest-lists" title="Guest Lists">Guest Lists</a></li>
<li class="page_item page-item-5"><a href="http://www.nightlifeguestlist.com/photogallery.php" title="Photo Gallery">Photo Gallery</a></li>
<li class="page_item page-item-7"><a href="http://www.nightlifeguestlist.com/video-gallery" title="Video Gallery">Video Gallery</a></li>
<li class="page_item page-item-9"><a href="http://www.nightlifeguestlist.com/jobs" title="Jobs">Jobs</a></li>
<li class="page_item page-item-11"><a href="http://www.nightlifeguestlist.com/membership" title="Mailing List">Mailing List</a></li>
<li class="page_item page-item-16"><a href="http://www.nightlifeguestlist.com/tables" title="Tables">Tables</a></li>

<li class="page_item page-item-13"><a href="http://www.nightlifeguestlist.com/event-management" title="Event Management">Event Management</a></li>
<li class="page_item page-item-538"><a href="http://www.nightlifeguestlist.com/blog" title="Blog">Gossip Blog</a></li>


        
</ul>
</div>
</div>
<!-- end nav -->


<div class="clear"></div> 
</div>

<!--/head -->
    
    <div class="narrowcolumn">


        
            <div class="entry">
              <div id="content-area">

              <!-- 1 -->
              <div id="section">
              
<? if($venue && !$event){ ?><?php
$pCount = 0;
$myNum = sprintf("%02d",$venue);
echo "<img  src='interiors/" . $myNum . "_logo.gif' vspace='2' hspace='2'>\n";
if ($handle = opendir('interiors')) {
   while (false !== ($file = readdir($handle))) {
       if (substr($file,0,6) == $myNum . "_pic") {
           echo '<img  src="interiors/' . $file . '" vspace="2" hspace="2">';
           if($pCount++ % 2 == 1) echo "";
       }
   }
   closedir($handle);
}
?>

<? } ?>

<? if(!$location){?>

              
              <!-- 2 -->
              <div id="section">
<?
do{
    $query_latest = "SELECT ec_venues.venue_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_venues.venue_id, ec_events.event_id FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ((ec_events.event_date) IS NOT NULL) AND ec_venues.location='".$row_events['location']."' ORDER BY UNIX_TIMESTAMP(ec_events.event_date) DESC LIMIT 0,1";
    $latest = mysql_query($query_latest, $nightlife2 ) or die(mysql_error());
    $row_latest = mysql_fetch_assoc($latest);
    $totalRows_latest = mysql_num_rows($latest);
?>
<a href="club_dates/<?=$row_events['location']?>/<?=$row_latest['venue_id']?>/<?=$row_latest['event_id']?>/<?=str_replace(" ","_",$row_latest['venue_name'])?>_page1.htm    "><?=$row_events['location']?> - <?php echo date("l jS F",$row_latest['event_date']); ?> @ <?php echo $row_latest['venue_name']; ?></a><br>
          <?
    } while ($row_events = mysql_fetch_assoc($events));
    mysql_free_result($latest);
?>    
              </div>
              <!-- 3 -->
              <div id="section">
              <? } else if(!$venue){ ?>
              </div>
              
               <!-- 4 -->
              <div id="section">
            Our most recent event was <strong><a style="color:#000000; font-weight:bold;" href="club_dates/<?=$row_events['location']?>/<?=$row_events['venue_id']?>/<?=$row_events['event_id']?>/<?=str_replace(" ","_",$row_events['venue_name'])?>_page1.htm    "><?php echo date("l jS F",$row_events['event_date']); ?> @ <?php echo $row_events['venue_name']; ?></a></strong>

      <? } else if($venue && !$event){?>
              </div>
              
              <!-- 5 -->
              <div id="section">
              <table width="100%" border="0" align="left" cellpadding="0" cellspacing="10">
                    <tr>
                      <td colspan="4"><? if($totalRows_events==0){ ?>
                        No photos are avaliable yet for this venue.
                        <? } else { ?>
                        Select a Date for <?php echo $row_events['venue_name']; ?>
                        <? } ?>                      </td>
                    </tr>
                    <? $count = 0; 
                         do { 
        
        if($count % 3 == 0){ echo '<tr>'; }
?>
                    <td width="713"><a style="color:#000000; font-weight:bold;" href="club_dates/<?=$location?>/<?=$venue?>/<?=$row_events['event_id']?>/<?=str_replace(" ","_",$row_events['venue_name'])?>_page1.htm"><? echo ($row_events['event_date']==""?$row_events['event_name']:date("D, j F y",$row_events['event_date'])); ?></a></td>
                      <?php 
        if($count % 3 == 2){ echo "</tr>"; }
        $count++;
        } while ($row_events = mysql_fetch_assoc($events));
        echo str_repeat("<td> </td>",4-($count % 4)); ?>
    </table>
              </div>
              
              <!-- 6 -->
              <div id="section">
              <? } else if($venue && $event){ ?>
              </div>
              
              <!-- 7 -->
              <div id="section">
              <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
                      <tr>
                        <td><?
    if ($dir = @opendir("photos/".$row_events['image_folder'])){
        while (($file = readdir($dir)) !== false) {
            if(substr($file,0,4) == "page"){
                $dirlist[] = $file;
            }
        }
        sort ($dirlist); 
        reset ($dirlist); 
        closedir($dir);
    }
    if ($dir = @opendir("photos/".$row_events['image_folder']."/".$dirlist[$page])){
           while (false !== ($file = readdir($dir))) { 
            if(substr($file,-3)=="jpg"){
                $imglist[] = $file;
            }
           } 
        usort($imglist,"strnatcmp"); 
        reset ($imglist); 
        closedir($dir);
    }
$count = 0;
$paging = "";
if($page==0){ 
    $paging .= "<< ";
} else $paging .= "<a href='/club_dates/".$location."/".$venue."/".$event."/".str_replace(" ","_",$row_events['venue_name'])."_page".($page).".htm' style='color:#000000; font-weight:bold;'><<</a> ";
foreach($dirlist as $f){
       if($page!=$count){
        $paging .= "<a href='/club_dates/".$location."/".$venue."/".$event."/".str_replace(" ","_",$row_events['venue_name'])."_page".($count+1).".htm' style='color:#000000; font-weight:bold;'>".($count+1)."</a> ";
    } else {
        $paging .=  ($count+1)." ";
    }
    $count++;
}
if($page==count($dirlist)-1){ 
    $paging .= ">> ";
} else $paging .= "<a href='/club_dates/".$location."/".$venue."/".$event."/".str_replace(" ","_",$row_events['venue_name'])."_page".($page+2).".htm' style='color:#000000; font-weight:bold;'>>></a>";
?></td>
                      </tr>
                      <tr>
                        <td><? echo "<table width='720'><tr><td>Nightlife Guestlist @ ".$row_events['venue_name'].($row_events['event_date']!="" ?" - ".date("l jS F Y", $row_events['event_date']) : "")." - ".$location."</td><td align='right'>".$paging."</td></tr></table>\n"; ?></td>
                      </tr>
                      <tr>
                        <td><?
    for($count=0;$count<count($imglist);$count++){
        echo "<a href='javascript:;'><img alt='".$imglist[$count]." @ ".$location." Club ".$row_events['venue_name'].", ".date("jS F Y", $row_events['event_date'])."' border='0' width='90px' height='60px' hspace='5px' vspace='5px' src='"."photos/".$row_events['image_folder']."/".$dirlist[$page]."/thumbs/".$imglist[$count]."' onclick='NewWindow(\"/popup.php?t=".count($imglist)."&n=".$count."&f=".$row_events['image_folder']."&p=".$dirlist[$page]."&title=".urlencode($location." Club ".$row_events['venue_name']." on ".date("jS F Y", $row_events['event_date']))."\",\"name\",\"600\",\"420\",\"no\");return false;'></a>\n";
        if($count % 7 == 6){ echo "<br>\n"; }
    } ?>
                            <? } ?></td>
                      </tr>
                      <tr>
                        <td> </td>
                      </tr>
                </table>
              </div>
              
              <div  id="section">
              <?
if(!$location){
?>
                      <?
} else {
    include("getClubLogos.php");
}
?> 

 

(Sorry for the amount of code!)

 

I use the same code for another site on another server and it works fine.

 

I guess I need to alter the code somehow? The gallery works ok just the dates show are wrong. Any ideas on how to fix this?

 

The server settings/time seems are OK.

 

The line which prints the date is:

<? echo ($row_events['event_date']==""?$row_events['event_name']:date ("D, j F y",  $row_events['event_date'])) ; ?>

 

When I echo the date

echo date('c');

I receive 2010-10-29T23:00:00+00:00 for Fri, 29 October 10.

 

Thanks

Link to comment
Share on other sites

In the database the date is in putted as 2010-10-30.

...

date ("D, j F y",  $row_events['event_date']))

the date function takes unix timestamps as its second operator, not a formatted date.

 

if date("c") is returning the wrong date, then it would seem your server is set in a different timezone?

http://www.php.net/manual/en/function.date-default-timezone-set.php

or

//timezone php. change australia/sydney to your timezone as listed on the PHP.net site
putenv('TZ=Australia/Sydney');

 

Link to comment
Share on other sites

Hey, thanks for your help.

 

The server seems to be OK i have created this file which simply echo's c http://www.nightlifeguestlist.com/datetest.php and it shows the server time is fine.

 

2010-10-30 from the database is returned as 2010-10-29T23:00:00+00:00 when i change:

 

<? echo ($row_events['event_date']==""?$row_events['event_name']:date ("D, j F y",  $row_events['event_date'])) ; ?>

 

to

 

<? echo ($row_events['event_date']==""?$row_events['event_name']:date ("c",  $row_events['event_date'])) ; ?>

 

I'm seriously puzzled by this! :(

 

I've asked around but no one has been able to find the solution.

 

 

Link to comment
Share on other sites

This returns the date of the event. Without this the code breaks down (i.e. white page!)

 

The code is quite old so it's more complex than it needs to be, it's something which I have inherited from another developer 3/4 years ago. I'd love to upgrade the system but the client is not willing to invest.

 

I did have the thought of adding an hour to:

 

<? echo ($row_events['event_date']==""?$row_events['event_name']:date ("D, j F y",  $row_events['event_date'])) ; ?>

 

Any idea how to do this?

 

I'm thinking that might work.

 

Link to comment
Share on other sites

all depends on what $row_events['event_date'] returns (format)

echo $row_events['event_date']; and post it here.

 

The whole code

<? echo ($row_events['event_date']==""?$row_events['event_name']:date ("D, j F y",  $row_events['event_date'])) ; ?>

echo's a result such as:

 

Fri, 29 October 10

Link to comment
Share on other sites

but what does $row_events['event_date'] echo by itself?

 

change the line

<? echo ($row_events['event_date']==""?$row_events['event_name']:date ("D, j F y",  $row_events['event_date'])) ; ?>

 

to

exit("<p>Value: ".$row_events['event_date']).'</p>';

 

and post whatever value it prints

Link to comment
Share on other sites

seems your server's timezone is set to somewhere around the u.s.a.

 

do this to check

echo date('e');
exit();

 

to set your timezone, use date_default_timezone_set()

a list of timezones are here

 

i.e.

//using server's timezone
    echo date('e g:ia d/m/y', 1288393200) . '<br/>';

//change to london
date_default_timezone_set('Europe/London');
//same command using london timezone.
    echo date("e d/m/y g:ia", 1288393200);

exit();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.