Page 1 of 1

Translate month with PHP

Posted: Fri Jul 09, 2010 2:28 am
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

Re: Translate month with PHP

Posted: Fri Jul 09, 2010 3:36 am
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.

Re: Translate month with PHP

Posted: Fri Jul 09, 2010 4:18 am
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';

Re: Translate month with PHP

Posted: Fri Jul 09, 2010 6:03 am
by Okoth
Thanks guys,

A combination of your replies worked!