Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with php date formation and mysql

Guest
Apr 09, 2010 Apr 09, 2010

Dear,

I am outputing date colum from mysql, and it is like this 2010-02-23 and I would like it to echo like (February 2010)

Or something esle that could help, is, a way to insert only a part of a date in myslq, I mean a way to allow a user to enter a usual date which could be Cdate or simply in putted and (ex. 2010-03-12), then have php convert it to 2010 March, before it get inserted.

Any help is welcome, and please don't refference me to w3school, or the mysql manuel, I have been there and got nothing, expect the DATE_FORMAT, but since I have rather a complicated query, I would like to format just the echoed individual colum.

Thanks

R.

TOPICS
Server side applications
638
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 09, 2010 Apr 09, 2010

I'm sorry that you don't want to learn the right way to do this... but DATE_FORMAT *is* what you need to do.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2010 Apr 11, 2010

Yes, you're right, but the problem is, when I link to get the archive using URL parameter, this is what I get in my browser January 2010 (for example) but on the output page, I don't how to get the same format for the query to work, I am kind of stuck, and don't even know how to explain this, I can send you a copy of the code if that might help more.

R.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2010 Apr 11, 2010

Got the query to work, using the contains argument, so I am giving your the credit anyway.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2010 Apr 11, 2010

Have you tried just adjusting your sql query using date_format?

SELECT DATE_FORMAT(date_column_name, '%M %Y')

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 11, 2010 Apr 11, 2010
LATEST

I tried that, didn't work, so now I used the same query, without changing anything, but instead of = to URL p. I use

d, contains and double my link, with one displaying January 2010 and the url sending 2010-01

so now, I can get the result I want while keeping my format,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines