Discussion

Welcome to Absolute Web Dev Forum. Feel free to Register and ask me a question about web development or, if you can answer or contribute to the aswering of someones question, feel free to respond. All listings are reviewed by me so please make your comments usefull. If you will, please leave links to related websites or other references that someone can go to for further information on a given subject. Thank you for your contribution to Absolute Web Devs Web Forum.Create Discussion

How did you format the date on the home page of this site?

Casey

How did you format the date on the home page of this site?   -   12/25/2008


Hey WebMaster! I wanted to know how you formatted the date from the database of your website. You placed the date into handy dandy little boxes. Please give me a heads up so I can do something similar in my site. Thanks Mans ;-)

WebMaster

Response   -   12/252009


I used php regular expressions to get parts of the date that I wanted and then formatted it using css. The following is the php code I made to extract certian parts of the date in my database.

//Get the Year
$ydate = $row['event_date'];
$ydate = preg_replace('@(\b\d+\b\/)@', '', $ydate);

//Get the Month
$mdate = $row['event_date'];
$mdate = preg_replace('@(\/\b\d+\b\/\b\d+\b)@', '', $mdate);

$month['01'] = "January";
$month['02'] = "February";
$month['03'] = "March";
$month['04'] = "April";
$month['05'] = "May";
$month['06'] = "June";
$month['07'] = "July";
$month['08'] = "August";
$month['09'] = "September";
$month['10'] = "October";
$month['11'] = "November";
$month['12'] = "December";

//Get the Day
$ddate = '&' . $row['event_date'] . '&';
$ddate = preg_replace('@(\&\b\d+\b\/)@', '', $ddate);
$ddate = preg_replace('@(\/\b\d+\b\&)@', '', $ddate);

After I get the month, day, and year, I format the outcome into CSS div tags.

Add to this Discussion

Discussion Archive


TOP

  100% compatible with:
Firefox Explorer Opera Safari Flock Netscape Chrome

 100% valid CSS 3.0 and XHTML 1.0.
Valid CSS Valid XHTML