picokojama Posted December 12, 2012 Share Posted December 12, 2012 Hi! I have one issue with date translating. Here is my code: <?php $day = date("l"); $daynum = date("j"); $month = date("M"); $year = date("Y"); if($day == "Monday"){ $day = "Ponedjeljak"; }elseif($day == "Tuesday"){ $day = "Utorak"; } /* etc, translating day */ if($month == "January"){ $month = "siječnja"; }elseif($month == "February"){ $month = "veljače"; } /* etc, translating month */ elseif($month == "December"){ $month = "prosinca"; } echo $day . ", " . $daynum . ". " . $month . " " . $year . "."; ?> Now, problem is: Why output is "Utorak, 11. Dec 2012." (there should be "Utorak, 11. prosinca 2012.")? It translated only day, but not month, although code for month is similar to code for day. Link to comment Share on other sites More sharing options...
satishpoul Posted December 12, 2012 Share Posted December 12, 2012 becouse your output is Dec not Decmber so specify condition for Dec also Link to comment Share on other sites More sharing options...
thescientist Posted December 12, 2012 Share Posted December 12, 2012 (edited) in the documentation, it will show you what value you will be getting back from this line $month = date("M"); http://php.net/manua...nction.date.php M A short textual representation of a month, three letters JAN through DEC so as in the previous post, you should be checking against the short representation. also, you might want to consider an array to do the mappings, so you don't have super long if/else conditionals, i.e.$dayMapper = array( 'Monday' => 'Ponedjeljak','Tuesday' => 'Utorak'); echo 'today is => ' + $dayMapper[date('l')]); Edited December 12, 2012 by thescientist Link to comment Share on other sites More sharing options...
picokojama Posted December 12, 2012 Author Share Posted December 12, 2012 Thank you guys very much 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now