RyanSmith Posted January 11, 2005 Posted January 11, 2005 Hello, I'm writing a custom attributes system and the values get pulled from a new table in the database. Two of these field are date values defined as datetime fields in the database. I was wondering how I can format these dates so they appear in the format 'June 21, 2005' or the like. Does anyone know where I can find this information??? Thanks osCommerce is a great piece of software with wonderful contributions. Spend some time in the contribution area. There are a lot of gems there.
Guest Posted January 11, 2005 Posted January 11, 2005 $query = tep_db_fetch_array(tep_db_query("select UNIX_TIMESTAMP(min(some_date)) as timestamp FROM some_table")); # Returns the timestamp... $formatted_date = date(" j F, Y", $query['timestamp']); # Formats it like 21 June, 2005 Bobby
RyanSmith Posted January 11, 2005 Author Posted January 11, 2005 $query = tep_db_fetch_array(tep_db_query("select UNIX_TIMESTAMP(min(some_date)) as timestamp FROM some_table")); # Returns the timestamp... $formatted_date = date(" j F, Y", $query['timestamp']); # Formats it like 21 June, 2005 Bobby <{POST_SNAPBACK}> Thanks, I already figured it out. My query looks like: $pc = tep_db_query("SELECT camp_id, camp_city, camp_state, DATE_FORMAT(start_date, '%M %D') as start_date, DATE_FORMAT(end_date, '%M %D %Y') as end_date FROM camps WHERE camp_id = " . (int)$pc_val); and it prints exactly how I want it. Thanks again for your reply. osCommerce is a great piece of software with wonderful contributions. Spend some time in the contribution area. There are a lot of gems there.
Guest Posted January 11, 2005 Posted January 11, 2005 That works too..I'm just used to getting everything in a timestamp so it can be manipulated any way needed. ...another proof that there is more than one way to skin a cat :) Bobby
RyanSmith Posted January 11, 2005 Author Posted January 11, 2005 ...another proof that there is more than one way to skin a cat :) Bobby <{POST_SNAPBACK}> Isn't that the truth. osCommerce is a great piece of software with wonderful contributions. Spend some time in the contribution area. There are a lot of gems there.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.