/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@phantom007authorMar 17.2008 — Yes, I have looked into that already. Doesnt solve my purpose. ?
Copy linkTweet thisAlerts:
@NogDogMar 17.2008 — Can you show us what you have tried? I can see no reason why the MySQL DATE_FORMAT() function could not do it, assuming the date/time is stored in an appropriate column type.

If you really, really feel you must do the conversion on the PHP side, look at the [url=http://www.php.net/strtotime]strtotime[/url]() function to convert the string to a PHP UNIX time integer, then use that value with [url=http://www.php.net/date]date[/url]() to get the desired format.
Copy linkTweet thisAlerts:
@ss1289Mar 17.2008 — what is the purpose?
Copy linkTweet thisAlerts:
@HuevoosMar 17.2008 — As NogDog said it's better to retrieve it with the mysql date_format, but if you really want to do it in php you should use the UNIX_TIMESTAMP(date) function in mysql
×

Success!

Help @phantom007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...