Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Formatting dates from database


RyanSmith

Recommended Posts

Posted

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.

Posted

$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

Posted
$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

 

 

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.

Posted

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

Posted
...another proof that there is more than one way to skin a cat :)

 

Bobby

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...