Jump to content

date and strtotime


pound!

Recommended Posts

Hi,

 

I'm pulling data from mysql and need to reformat the eventDate field as d M Y.

 

I've used strtotime in another script but have never used it when 'echo'ing out a xml.

 

At the moment this is what I have, but it obviously isn't working.

 

<?PHP

$link = mysql_connect(xxxxxx);
mysql_select_db(xxxxx);

$query = 'SELECT * FROM `events` WHERE eventLocation NOT LIKE "Mel" AND eventDate BETWEEN CURDATE() AND CURDATE() + INTERVAL 7 DAY ORDER BY eventDate';
$results = mysql_query($query);

echo "<?xml version=\"1.0\"?>\n";
echo "<comingEvents>\n";
while($line = mysql_fetch_assoc($results)) {
$eDate = date("d M Y", strtotime("eventDate"));
echo "<event>\n";
	echo "<eventDate>" . $line["$eDate"] . "</eventDate>\n";
	echo "<link>" . $line["eventLink"] . "</link>\n";
	echo "<eventName>" . $line["eventName"] . "</eventName>\n";
echo "</event>\n";
}
echo "</comingEvents>\n";

mysql_close($link);

?>

 

Can someone please push me in the right direction.

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/193416-date-and-strtotime/
Share on other sites

Hi and thanks for the quick response,

 

The error is...

 

 

Warning: date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in F:\websites\thelocal.com.au\SYD\scripts\frontPageEventsSYD.php on line 15

Mardi Gras

Warning: date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in F:\websites\thelocal.com.au\SYD\scripts\frontPageEventsSYD.php on line 15

 

The xml source is

 

<?xml version="1.0"?>
<comingEvents>
<br />
<b>Warning</b>:  date() [<a href='function.date'>function.date</a>]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in <b>F:\websites\thelocal.com.au\SYD\scripts\frontPageEventsSYD.php</b> on line <b>15</b><br />
<event>
<eventDate></eventDate>
<link></link>
<eventName>Mardi Gras</eventName>

</event>
<br />
<b>Warning</b>:  date() [<a href='function.date'>function.date</a>]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in <b>F:\websites\thelocal.com.au\SYD\scripts\frontPageEventsSYD.php</b> on line <b>15</b><br />
<event>
<eventDate></eventDate>
<link>http://thelocaltaphouse.blogspot.com/search?q=ale stars</link>
<eventName>Ale Stars - March - What the Bock?</eventName>

</event>
</comingEvents>

Link to comment
https://forums.phpfreaks.com/topic/193416-date-and-strtotime/#findComment-1018334
Share on other sites

If you're dealing with dates from before the year 1700 why would you need timestamp accuracy in the first place, but anyway its impossible since the valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) The problem with Windows is that it doesn't support negative timestamps.

 

So the question remains, why do you need timestamps from that long ago, you wouldn't have had records to the second anyway. I'm sure that back then records to the day if not even month could have been inaccurate....

Link to comment
https://forums.phpfreaks.com/topic/193416-date-and-strtotime/#findComment-1018337
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.