Hi
I have a date and time in one column as for example 2008-04-16 10:41:20.
I would like to do a ereg_replace so that the date and time will be converted only to date as 2008/04/16
I want to add the code to this
echo '<p> <a href=" '/' . $row['post_date'] . '/' . $row['post_name'] . '/ ">' . $row['post_title'] . '</a> <br>'. strip_tags(substr($row['post_content'],0,300)) . '';
so that $row['post_date'] changes to the new date structure and the URL will now read
http://www.bambooclat.com/2008/04/16/post_name/
thanks a bunch
Neal
ereg on date and time
Moderator: General Moderators
- andyhoneycutt
- Forum Contributor
- Posts: 468
- Joined: Wed Aug 27, 2008 10:02 am
- Location: Idaho Falls
Re: ereg on date and time
you could just use a combination of date() and strtotime():
-Andy
Code: Select all
$post_date = date("Y/m/d",strtotime($row['post_date']));Re: ereg on date and time
thank you. I had to add one more thing to it to make it work the way i wanted it to. Here is what it now looks like
. $row['post_date'] = date("Y/m/d",strtotime($row['post_date']))
. $row['post_date'] = date("Y/m/d",strtotime($row['post_date']))
Re: ereg on date and time
By the way, you might want to learn pcre (preg_functions) because ereg is depreciated in 5.3.0 and will be removed in 6.0.0
Re: ereg on date and time
thanks a million. i will follow up on this