Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 2008-03-17, 03:21 AM
Junior Member
 
Join Date: Dec 2007
Posts: 6
cancer10 is on a distinguished road
Question MySQL Timestamp into PHP Format

I have a timestamp column in a mysql table.

Using PHP, how do I convert the timestamp format which is "YYYY-MM-DD HH:MM:SS" into a format like "March 16 2008, 08:41 am" ?


Please help



Thanx
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2008-03-18, 06:11 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,096
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

That is a date column, not timestamp. And sadly enough, that means just a little more work for you.

There are two ways to do this, one is using PHP. You can use the function mktime() (PHP: mktime - Manual) to plug in your output and use date() to get the exact format you want.....

Or, just use MySQL to do it. (MySQL :: MySQL 5.0 Reference Manual :: 11.6 Date and Time Functions)

So you will do something like:

select date_format('<FORMAT YOU WANT>', date_column_name) from table etc....
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2008-04-14, 01:18 AM
Junior Member
 
Join Date: Apr 2008
Location: Cheltenham, UK
Posts: 11
hoopyfrood is on a distinguished road
Default date conversion

Hi cancer10,

I'd recommend you use date() function, do not forget to convert the MySQL timestamp into PHP readable format using strtotime().

I normally use
PHP Code:
date('d/m/Y'strtotime($some_array['my_timestamp)) 
Hope it helps,
__________________
Love your documents!

DocuView - The best Web 2.0 document management system (DMS) - utilising the latest technology to help your company achieve ISO 9001 certification.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:21 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.