tags:

views:

82

answers:

3

Hi.

have one problem, I need the dates in Swedish format, for instance, october is in swedish oktober... How can I do this?

This works so far for english dates:

      $date = date( "j F", strtotime( $row[insert_date] ) );

$display_table .= "$date";

+2  A: 

Something like this might help:

$date = date( "j F", strtotime( $row[insert_date] ) );
$display_table .= "<td width='67' rowspan='2'>$date</td>";
Rudisimo
how about swedish dates? october in swedish is oktober... is there a simple way to solve this?
Camran
@camran - Set the locale before performing the query: "SET lc_time_names = 'sv_SE';"
Mark
update to my last comment, that is assuming you are using my solution posted, not Rudisimo's
Mark
is there a way to check if a letter in the script you gave me rudismo, has a value...?example: if $date = october then = oktober?
Camran
@Rudisimo, that functionality is already built in to PHP with strftime(): http://php.net/manual/en/function.strftime.php. I feel the my mysql solution is simpler however as it negates the need for all of these php function calls
Mark
+1  A: 

An alternative to Rudisimo's answer is making mysql do the work for you:

SELECT DATE_FORMAT(`insert_date`,'%d %M') AS insert_date FROM `table_name` WHERE [...]
Mark
please explain more about this... Im currently using fetch array in a while loop for my table... give me some hints please
Camran
You just need to add the following into your SQL statement: "DATE_FORMAT(`insert_date`,'%d %M') AS insert_date". That will override the value for $row[insert_date] with a formatted version of the date. You won't need to adjust anything else in your php code
Mark
A: 

you can set the language using locale and then use the mysql date_format or php strftime()

heres a website that will help you format the date http://www.mysqlformatdate.com

gerard