How to change the name of days and months?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

How to change the name of days and months?

Post by MicroBoy »

How to change the name of days and months into my language, example from Monday to E Hënë etc... The function that I use is date();
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: How to change the name of days and months?

Post by John Cartwright »

I'm not sure what language you are using, but you can use set the locale using (example is dutch)

Code: Select all

set_locale(LC_TIME, , 'nl_NL');
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: How to change the name of days and months?

Post by jayshields »

You might just have to make arrays of whatever language you want to convert into and do it that way, unless there's something on http://www.php.net/manual/en/ref.calendar.php
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: How to change the name of days and months?

Post by MicroBoy »

My language is Albanian, usually it uses SQ prefix. Where I have to put:

Code: Select all

set_locale(LC_TIME, , 'nl_NL');
or that array? I use this for my date and time

Code: Select all

$time= date("l d F Y, H:i:s");
 
//then I insert it to DataBase by://
 
$sql="INSERT INTO lajmet (name, news, time)
 
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: How to change the name of days and months?

Post by John Cartwright »

You'll need to use strftime() to format the date per the locale settings. In your case, the format would be

Code: Select all

$time = strftime("%A %d %B %Y, %T");
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: How to change the name of days and months?

Post by MicroBoy »

When I Use Like this:

Code: Select all

setlocale(LC_ALL, 'nld_nld');
$time= strftime("%A %d %B %Y")
It works good, but when I try to add the time like you wrote:

Code: Select all

$time = strftime("%A %d %B %Y, %T");
It Does't show neither date or time.

Can you tell me where I can find the code that php uses for states because I don't know what I have to use for Albanian language.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: How to change the name of days and months?

Post by John Cartwright »

Take a look at http://ca.php.net/manual/en/function.strftime.php, it seems not all the formats are supported on all platforms.
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: How to change the name of days and months?

Post by MicroBoy »

Everything it's ok but my months and days now are in lowercase can I change that the first word would be in uppercase?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: How to change the name of days and months?

Post by jayshields »

Code: Select all

strtoupper()
?
phpfrq
Forum Newbie
Posts: 1
Joined: Tue Mar 10, 2009 2:06 pm

Re: How to change the name of days and months?

Post by phpfrq »

putenv("TZ=ASIA/Dhaka"); // My timezone
$thedate=date("U"); //get unix timestamp
$displaytime=date("F j, Y, g:i a");
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: How to change the name of days and months?

Post by MicroBoy »

jayshields wrote:

Code: Select all

strtoupper()
?
Thnx a lot, this is exactly what I want ucwords() I found in php.net while I was seeing for strtoupper().

Now I have another problem, my language has a letter that is "ë" but in web-page it shows me like a symbol, when I log in phpmyadmin I can see that there is ë but in WeBPage it doesn't show like ë, but like a symbol. I converted the .php file into "UTF-8 Without BOM" cause everytime this worked for me, but now for the date it doesn't work this thing.
Post Reply