?
Solved

string input of a date I want to change and output

Posted on 2003-02-19
6
Medium Priority
?
267 Views
Last Modified: 2008-03-06
i am grabbing the date a table in my DB was last changed.  I've got the date but it is in the format:
2003-02-20 05:14:10
I want to change it to
Month day, year

but if I do something (or anything) like this:

$updated = date("F d, Y", "2003-02-20 05:14:10");

It will only take the "2003" and drop the rest.  

Any suggestions???

0
Comment
Question by:joshence
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:cneelus
ID: 7985660
You can use this
$updated = date("F d, Y", mktime(5,14,10,02,20,2003));
0
 
LVL 2

Expert Comment

by:laurly
ID: 7985917
if you are using mysql there is a function called date_format for formating dates

manual entry:
http://www.mysql.com/doc/en/Date_and_time_functions.html

example:
SELECT DATE_FORMAT('2003-02-20 05:14:10','%m-%D-%Y');


laurly
0
 
LVL 6

Expert Comment

by:carchitect
ID: 7986090
yeah laurly is right and i am late....
date_format will sole your purpose....

SELECT DATE_FORMAT(2003-02-20 05:14:10','%m %e,%Y');

regards


0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 

Author Comment

by:joshence
ID: 7987854
I like what laurly has to say, and I think I can get it to work...but as of now it is a no go.  Here is my SQL Query:

show table status from *database* like '*tablename*';

and that returns an array with a "column name" called Update_time along with many others (not all dates).

So my new question is.  How can I get mySql to pull ONLY that column and then arrange the date the way I want.  


Joshua
0
 
LVL 1

Accepted Solution

by:
s-maxim earned 400 total points
ID: 7988159
Then, your could also use the PHP native function strtotime() for recognizing the date's format:

$new_date = date("F d, Y", strtotime($date_returned_from_db));

Maxim Maletsky
maxim@php.net
0
 

Author Comment

by:joshence
ID: 7988399
s-maxim,
Thanks...that was the function I was looking for.  Very nice.  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question