komquat Posted October 12, 2006 Share Posted October 12, 2006 I am looking to highlight one line from the information I pull from a DB.The current format of the DB is 2006-02-19I want to have a list of all dates and highlight the next one in the sequence according to today. ExWeek 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 Link to comment https://forums.phpfreaks.com/topic/23759-need-help-with-date/ Share on other sites More sharing options...
komquat Posted October 13, 2006 Author Share Posted October 13, 2006 Anyone good with dates and things, please give a hand.Thanks in advance Link to comment https://forums.phpfreaks.com/topic/23759-need-help-with-date/#findComment-108371 Share on other sites More sharing options...
xsist10 Posted October 13, 2006 Share Posted October 13, 2006 Hey... what you want is to turn the timestamp into a unix timestamp like so:[code]<?phpfunction 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] Link to comment https://forums.phpfreaks.com/topic/23759-need-help-with-date/#findComment-108380 Share on other sites More sharing options...
komquat Posted October 19, 2006 Author Share Posted October 19, 2006 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 Link to comment https://forums.phpfreaks.com/topic/23759-need-help-with-date/#findComment-111590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.