Translate month with PHP

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
Okoth
Forum Newbie
Posts: 4
Joined: Sat Feb 28, 2009 4:04 am

Translate month with PHP

Post by Okoth »

I am trying to translate the current month into another language with php. It is part of WordPress, month of posting the post.

I have tried this, but it doesn't work

Code: Select all

<?php $mnth = the_time('M');
if ($mnth = 'Mar') $imnth = 'Mrt';
if ($mnth = 'May') $imnth = 'Mei'; 
if ($mnth = 'Oct') $imnth = 'Okt';
?>                 
<p class="date">
<span class="month"><?php $imnth; ?></span>
I have no clue how to solve it because I don't know much about PHP. It shouldn't be too difficult though.

Can someone help me with this?
Thanks
rhecker
Forum Contributor
Posts: 178
Joined: Fri Jul 11, 2008 5:49 pm

Re: Translate month with PHP

Post by rhecker »

I don't know anything about WordPress, but your PHP should be corrected as follows:

Code: Select all

if ($mnth == 'Mar') {$imnth = 'Mrt';}
Note that double equal means equal, but single equal creates assignment.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: Translate month with PHP

Post by pbs »

Try this

Code: Select all

	$mnth = date('M');
	if ($mnth == 'Mar') $imnth = 'Mrt';
	if ($mnth == 'May') $imnth = 'Mei'; 
	if ($mnth == 'Oct') $imnth = 'Okt';
Okoth
Forum Newbie
Posts: 4
Joined: Sat Feb 28, 2009 4:04 am

Re: Translate month with PHP

Post by Okoth »

Thanks guys,

A combination of your replies worked!
Post Reply