Avatar of rraymond1130
rraymond1130
 asked on

setlocale(LC_MONETARY, 'en_US'); not working on ubuntu 12.4

I have some php code displaying car prices. I'm using setlocale(LC_MONETARY, 'en_US'); to format the prices. Now this code works on my site hosted by Hostmonster, but on my ubuntu server this is not working. What could be the problem?

I forgot to add that this is not working either: money_format('%.0n' ,$row['InternetPrice']);
LinuxPHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
Ray Paseur

not working

Have you seen this link on the man page?
http://php.net/manual/en/function.money-format.php#86039

This also looks promising:
http://manpages.ubuntu.com/manpages/intrepid/man3/setlocale.3.html

Is there a symptom of failure that you might be able to share?  Is there a code example?  

Thanks, ~Ray
rraymond1130

ASKER
Here is the code that is being used below. It works on the site hosted by hostmonster which is a Linux server. I figured it would work on a ubuntu server also since its Linux. No errors being reported:

setlocale(LC_MONETARY, 'en_US'); //Set Currency to US. This will put a $ in front of the number
$intPrice = money_format('%.0n' ,$row['InternetPrice']); //This sets the format for the dollar amount to $##,### no cents

I get a feeling their may be a package that needs to be installed on ubuntu but don't know which.
ASKER CERTIFIED SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

Testing on my server, both en_US and en_US.UTF-8 worked correctly.

<?php // RAY_temp_rraymond1130.php
error_reporting(E_ALL);
echo "<pre>";

// SEE http://www.experts-exchange.com/OS/Linux/Q_28311139.html

$x = setlocale(LC_MONETARY, 'en_US.UTF-8');
var_dump($x);

$row['InternetPrice'] = '1234.56';
$y = money_format('%.0n' ,$row['InternetPrice']);
var_dump($y);

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
rraymond1130

ASKER
As usual Ray, Great Help!!!! Thanks
Ray Paseur

Thanks for the points and thanks for using EE! ~Ray