Forum Moderators: coopster

Message Too Old, No Replies

Selecting part of a value?

Probably an easy question...

         

johnglass

4:09 am on Apr 2, 2004 (gmt 0)

10+ Year Member



Hi,

Learning php and mysql, and frankly it's making my head spin... Anyway, how would you get a result and output only part of it? Like get "2004" and only output "04". It's probably a stupid question, but I can't seem to find the correct syntax in any of the manuals.

Specifically, I want to output the standard mysql "0000-00-00" date format as "mm/dd/yy". I know there are scripts out there for dates, but I don't want to do anything fancy with it, just switch some numbers around and output part of a result (plus I'm trying to learn this stuff, and this seems like a question that will provide answers for other things as well). An example script would help me alot.

From what I know so far, I think the answer would be to select the field, explode the string, then assign and output the variables with "/" in between.

But I could be wrong...

Thanx! :) JG

httpwebwitch

4:58 am on Apr 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



plenty of info at php.net

familiarize yourself with date() and substr(), they're handy functions

httpwebwitch

5:00 am on Apr 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo date("m/d/y",strtotime($mysqldate));

johnglass

7:43 am on Apr 2, 2004 (gmt 0)

10+ Year Member



ty for the response :)

yeah, i'm familiar with php.net, just didn't know exactly what to look for...

thank you for pointing the way and thank you for the script! :)

JG