Jump to content

Archived

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

komquat

need help with date()

Recommended Posts

I am looking to highlight one line from the information I pull from a DB.

The current format of the DB is 2006-02-19

I want to have a list of all dates and highlight the next one in the sequence according to today. 

Ex

Week Date Race Track
19. 2006-07-16 New England 300 New Hampshire International Sp
20. 2006-07-23 Pennsylvania 500 Pocono Raceway
21. 2008-06-06 Allstate 400 at the Brickyard Indianapolis Motor Speedway
22. 2006-08-13 Sirius Satellite Radio Watkins Glen International
23. 2006-08-20 GFS Marketplace 400 Michigan International Speedwa
24. 2006-08-26 Sharpie 500 Bristol Motor Speedway
25. 2006-09-03 Sony HD 500 California Speedway
26. 2006-09-09 Chevy Rock & Roll 400 Richmond International Raceway
27. 2006-09-17 Sylvania 300 New Hampshire International Sp
28. 2006-09-24 Dover 400 Dover International Speedway
29. 2006-10-01 Banquet 400 presented by ConAg Kansas Speedway
30. 2006-10-08 UAW-Ford 500 Talladega Superspeedway
31. 2006-10-14 Bank of America 500 Lowe's Motor Speedway
32. 2006-10-22 Subway 500 Martinsville Speedway
33. 2006-10-29 Bass Pro Shops MBNA 500 Atlanta Motor Speedway
34. 2006-11-05 Dickies 500 Texas Motor Speedway
35. 2006-11-12 Checker Auto Parts 500 Phoenix International Raceway
36. 2006-11-19 Ford 400 Homestead-Miami Speedway


I want line 31 highlighted and the rest in normal text. 

Please help

thanks in advance

Share this post


Link to post
Share on other sites
Anyone good with dates and things, please give a hand.

Thanks in advance

Share this post


Link to post
Share on other sites
Hey... what you want is to turn the timestamp into a unix timestamp like so:

[code]
<?php

function getTimeStamp($date) {
// 2006-05-10 00:00:00
// 0123456789012345678
return mktime( substr($date, 11, 2), // Hours
substr($date, 14, 2), // Minutes
substr($date, 17, 2), // Seconds
substr($date, 5, 2), // Months
substr($date, 8, 2), // Days
substr($date, 0, 4)); // Years
}

?>
[/code]

To look something like this

[code]
<?php

$highlighted = false;
foreach ($events as $event) {
echo $event["id"] .". ";
if (!$highlighted && time() < getTimeStamp($event["time"])) {
echo "<span style='color: #990099;'>". $event["time"] ."</span>";
$highlight = true;
} else {
echo $event["time"];
}

echo $event["otherdata"];
}

?>
[/code]

Share this post


Link to post
Share on other sites
If anyone is interested, I figured it out with MySQL!

Here is the code:
[code=php:0]
$sql_next = "SELECT sched_id, race_date, track, race, (day(curdate()))-(day(race_date)) as diff
FROM nascar_schedule
WHERE month(curdate()) = month(race_date) and day(curdate()) <= day(race_date)
and (day(curdate()))-(day(race_date)) >= '-7'
ORDER BY sched_id
";

[/code]

Week Date Race Track
19. 2006-07-16 New England 300 New Hampshire International Sp
20. 2006-07-23 Pennsylvania 500 Pocono Raceway
21. 2008-06-06 Allstate 400 at the Brickyard Indianapolis Motor Speedway
22. 2006-08-13 Sirius Satellite Radio Watkins Glen International
23. 2006-08-20 GFS Marketplace 400 Michigan International Speedwa
24. 2006-08-26 Sharpie 500 Bristol Motor Speedway
25. 2006-09-03 Sony HD 500 California Speedway
26. 2006-09-09 Chevy Rock & Roll 400 Richmond International Raceway
27. 2006-09-17 Sylvania 300 New Hampshire International Sp
28. 2006-09-24 Dover 400 Dover International Speedway
29. 2006-10-01 Banquet 400 presented by ConAg Kansas Speedway
30. 2006-10-08 UAW-Ford 500 Talladega Superspeedway
31. 2006-10-14 Bank of America 500 Lowe's Motor Speedway
[b]32. 2006-10-22 Subway 500 Martinsville Speedway [/b]
33. 2006-10-29 Bass Pro Shops MBNA 500 Atlanta Motor Speedway
34. 2006-11-05 Dickies 500 Texas Motor Speedway
35. 2006-11-12 Checker Auto Parts 500 Phoenix International Raceway
36. 2006-11-19 Ford 400 Homestead-Miami Speedway

Share this post


Link to post
Share on other sites

×

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.