Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 28th, 2003, 02:28 PM
Registered User
 
Join Date: Aug 2003
Location: Cwmbran, Gwent, United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default date mysql to php display

HI, hope someone can help, I have just done my forst data base, now obviously the date in mysql is yyyy mm dd but when my users see it on the web interface I want them to see dd mm yy - how do I do this, have tried various sql commands and php but still displays incorrectly.

Thanks in advance

Ya man!!!
Reply With Quote
  #2 (permalink)  
Old August 28th, 2003, 03:23 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can either format the date in your MySQL query or with PHP.

In MySQL, you'll need the DATE_FORMAT() function.
  http://www.mysql.com/doc/en/Date_and...functions.html

SELECT DATE_FORMAT(date_col, '%d %m %y')
  FROM table_name

You can do it in PHP using regular expressions. Take a look at preg_replace()
  http://www.php.net/preg_replace

Also, you can convert the MySQL date to a unix timestamp, and then convert that timestamp to a date format of your choosing. PHP's date() function is similar to MySQL's DATE_FORMAT().
  http://www.php.net/strtotime
  http://www.php.net/date

date('d m y', strtotime($mysql_date));



Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #3 (permalink)  
Old August 29th, 2003, 02:10 AM
Registered User
 
Join Date: Aug 2003
Location: Cwmbran, Gwent, United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:D:D

Many thanks Nik I will look at this today, have been wrestling with this for 2 days, appreciate your help.

G

Ya man!!!
Reply With Quote
  #4 (permalink)  
Old August 30th, 2003, 06:39 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did it work?

Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #5 (permalink)  
Old September 1st, 2003, 08:13 AM
Registered User
 
Join Date: Aug 2003
Location: Cwmbran, Gwent, United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Not yet, still srugling with it I'm new to PHP so not sure wher to be putting the command, my data base is generated by a software programme, got the entry to be accepted but when it run it comes back with a 'function undefined errror'!!!


Ya man!!!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
PHP Mysql with Flash based display robprell Beginning PHP 0 November 3rd, 2005 10:06 PM
sort by date mysql crmpicco Classic ASP Databases 1 March 4th, 2005 06:55 AM
mysql timestamp to php display lbunnell PHP Databases 2 January 20th, 2005 05:55 PM
Display all tables in a mySql database question mb92010 MySQL 1 April 9th, 2004 04:26 PM



All times are GMT -4. The time now is 06:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.