Jump to content

strip dashes in text


samoht

Recommended Posts

Hello again,

 

I know this must be easy but I couldn't find an answer on google.

 

I have a date returned from my db that is formated like 2007-07-10

I would like to hyper link that to the proper calendar page but I need the format to be 20070710

e.g. w/o the dashes

 

How can I do this easily??

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/59286-strip-dashes-in-text/
Share on other sites

Why not select it from the database in the format you want it in the program?

 

mysql> SELECT date_or_datetime_col, DATE_FORMAT(date_or_datetime_col,'%Y%m%d') FROM tbl;
+---------------------+--------------------------------------------+
| date_or_datetime_col| DATE_FORMAT(date_or_datetime_col,'%Y%m%d') |
+---------------------+--------------------------------------------+
| 2007-04-30 20:52:25 | 20070430                                   |
| 2007-04-27 12:00:00 | 20070427                                   |
| 2007-01-01 12:00:00 | 20070101                                   |
| 2006-05-01 00:00:00 | 20060501                                   |
| 2007-01-02 13:00:13 | 20070102                                   |
| 2007-03-31 09:00:00 | 20070331                                   |
| 2007-03-30 01:00:00 | 20070330                                   |
| 2007-05-01 00:00:00 | 20070501                                   |
+---------------------+--------------------------------------------+
8 rows in set (0.00 sec)

Link to comment
https://forums.phpfreaks.com/topic/59286-strip-dashes-in-text/#findComment-294481
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.