Mexico - Formatting standards & code snippets
Here is a complete list of standards and formats used in Mexico. It includes a full list of ISO codes, number, date, currency, telephone and address formats. You will also get code examples on how to perform the most common formatting operations in Java, C#, JavaScript and PHP. Multiple resource files are made available, mainly the complete list of states, in different formats such as CSV, XML, JSON, HTML and SQL.
What are the ISO-3166-1 codes for Mexico?
- Alpha-2: MX
- Alpha-3: MEX
- Numeric: 484
- Java Locale Code: es_MX
- .Net CultureInfo Code: es-MX
- PHP Locale Code: es_MX
What is the official language in Mexico?
- Spanish
What is the date format in Mexico?
The date format in Mexico is little-endian:
- Format: d/M/yyyy
Ex: 3/12/2014 for December 3rd 2014
Formatting a date in Java:
Locale locale = new Locale("es", "MX");
SimpleDateFormat sdf = new SimpleDateFormat("d/MM/yyyy", locale);
sdf.format(new Date());
Formatting a date in C#:
CultureInfo ci = CultureInfo.GetCultureInfo("es-MX");
DateTime.Now.ToString("d/MM/yyyy", ci);
Formatting a date in JavaScript:
let date = new Date();
date.toLocaleDateString('es-MX');
Formatting a date in PHP:
date("j/m/Y");
What is the time format in Mexico?
The time format in Mexico is mostly 12-hour notation, but 24-hour format is also commonly adopted.
- Format: h:mm[:ss] a.m.|p.m.
Ex: 9:00 a.m. for 09:00AM, and 9:00 p.m. for 09:00PM
Formatting time in Java:
Locale locale = new Locale("es", "MX");
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss aa", locale);
sdf.format(new Date());
Formatting time in C#:
CultureInfo ci = CultureInfo.GetCultureInfo("es-MX");
DateTime.Now.ToString("h:mm:ss tt", ci);
Formatting time in JavaScript:
let date = new Date();
date.toLocaleTimeString('es-MX', {hour12: true});
Formatting time in PHP:
date("g:i:s a");
What is the numeric format in Mexico?
- Format: 999,999,999.99
- Group Size: 3
- Grouping Character: , (comma)
- Decimal Character: . (dot)
Formatting numbers in Java:
Locale locale = new Locale("es", "MX");
NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);
numberFormat.format(999999999.99d);
Formatting numbers in C#:
double d = 999999999.99d;
d.ToString("n", CultureInfo.GetCultureInfo("es-MX")));
Formatting numbers in JavaScript:
let number = 999999999.99;
number.toLocaleString('es-MX');
Formatting numbers in PHP:
$fmt = new NumberFormatter($locale = 'es_MX', NumberFormatter::DECIMAL);
$fmt->format(999999999.99);
What is the currency format in Mexico?
- Format: $999,999,999.99
- Group Size: 3
- Grouping Character: , (comma)
- Decimal Character: . (dot)
- Currency Symbol: $
- Currency Symbol Position: Before number
- Currency Name: Mexican Peso (MXN)
Formatting currency in Java:
Locale locale = new Locale("es", "MX");
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(locale);
numberFormat.format(999999999.99d);
Formatting currency in C#:
double d = 999999999.99d;
d.ToString("c", CultureInfo.GetCultureInfo("es-MX")));
Formatting currency in JavaScript:
let number = 999999999.99;
number.toLocaleString('es-MX', {currency: 'MXN', style: 'currency'});
Formatting currency in PHP:
$fmt = new NumberFormatter($locale = 'es_MX', NumberFormatter::CURRENCY);
$fmt->format(999999999.99);
Download list of states for Mexico in CSV, JSON, HTML, SQL and XML
List of states: HTML - Select Control
------------------------
ISO_3166-2 code + name
------------------------
<select>
<option value="MX-CMX">Mexican Federal District</option>
<option value="MX-AGU">Aguascalientes</option>
<option value="MX-BCN">Baja California</option>
<option value="MX-BCS">Baja California Sur</option>
<option value="MX-CAM">Campeche</option>
<option value="MX-COA">Coahuila</option>
<option value="MX-COL">Colima</option>
<option value="MX-CHP">Chiapas</option>
<option value="MX-CHH">Chihuahua</option>
<option value="MX-DUR">Durango</option>
<option value="MX-GUA">Guanajuato</option>
<option value="MX-GRO">Guerrero</option>
<option value="MX-HID">Hidalgo</option>
<option value="MX-JAL">Jalisco</option>
<option value="MX-MEX">México</option>
<option value="MX-MIC">Michoacán</option>
<option value="MX-MOR">Morelos</option>
<option value="MX-NAY">Nayarit</option>
<option value="MX-NLE">Nuevo León</option>
<option value="MX-OAX">Oaxaca</option>
<option value="MX-PUE">Puebla</option>
<option value="MX-QUE">Querétaro</option>
<option value="MX-ROO">Quintana Roo</option>
<option value="MX-SLP">San Luis Potosí</option>
<option value="MX-SIN">Sinaloa</option>
<option value="MX-SON">Sonora</option>
<option value="MX-TAB">Tabasco</option>
<option value="MX-TAM">Tamaulipas</option>
<option value="MX-TLA">Tlaxcala</option>
<option value="MX-VER">Veracruz</option>
<option value="MX-YUC">Yucatán</option>
<option value="MX-ZAC">Zacatecas</option>
</select>
List of states: CSV
code,name
MX-CMX,"Mexican Federal District"
MX-AGU,"Aguascalientes"
MX-BCN,"Baja California"
MX-BCS,"Baja California Sur"
MX-CAM,"Campeche"
MX-COA,"Coahuila"
MX-COL,"Colima"
MX-CHP,"Chiapas"
MX-CHH,"Chihuahua"
MX-DUR,"Durango"
MX-GUA,"Guanajuato"
MX-GRO,"Guerrero"
MX-HID,"Hidalgo"
MX-JAL,"Jalisco"
MX-MEX,"México"
MX-MIC,"Michoacán"
MX-MOR,"Morelos"
MX-NAY,"Nayarit"
MX-NLE,"Nuevo León"
MX-OAX,"Oaxaca"
MX-PUE,"Puebla"
MX-QUE,"Querétaro"
MX-ROO,"Quintana Roo"
MX-SLP,"San Luis Potosí"
MX-SIN,"Sinaloa"
MX-SON,"Sonora"
MX-TAB,"Tabasco"
MX-TAM,"Tamaulipas"
MX-TLA,"Tlaxcala"
MX-VER,"Veracruz"
MX-YUC,"Yucatán"
MX-ZAC,"Zacatecas"
List of states: JSON
------------------------
ISO-3166-2 code + Name
------------------------
[
{code: "MX-CMX", name: "Mexican Federal District"},
{code: "MX-AGU", name: "Aguascalientes"},
{code: "MX-BCN", name: "Baja California"},
{code: "MX-BCS", name: "Baja California Sur"},
{code: "MX-CAM", name: "Campeche"},
{code: "MX-COA", name: "Coahuila"},
{code: "MX-COL", name: "Colima"},
{code: "MX-CHP", name: "Chiapas"},
{code: "MX-CHH", name: "Chihuahua"},
{code: "MX-DUR", name: "Durango"},
{code: "MX-GUA", name: "Guanajuato"},
{code: "MX-GRO", name: "Guerrero"},
{code: "MX-HID", name: "Hidalgo"},
{code: "MX-JAL", name: "Jalisco"},
{code: "MX-MEX", name: "México"},
{code: "MX-MIC", name: "Michoacán"},
{code: "MX-MOR", name: "Morelos"},
{code: "MX-NAY", name: "Nayarit"},
{code: "MX-NLE", name: "Nuevo León"},
{code: "MX-OAX", name: "Oaxaca"},
{code: "MX-PUE", name: "Puebla"},
{code: "MX-QUE", name: "Querétaro"},
{code: "MX-ROO", name: "Quintana Roo"},
{code: "MX-SLP", name: "San Luis Potosí"},
{code: "MX-SIN", name: "Sinaloa"},
{code: "MX-SON", name: "Sonora"},
{code: "MX-TAB", name: "Tabasco"},
{code: "MX-TAM", name: "Tamaulipas"},
{code: "MX-TLA", name: "Tlaxcala"},
{code: "MX-VER", name: "Veracruz"},
{code: "MX-YUC", name: "Yucatán"},
{code: "MX-ZAC", name: "Zacatecas"}
]
List of states: SQL
-- -----------------------------------------------------
-- Table `state`
-- -----------------------------------------------------
DROP TABLE IF EXISTS state;
CREATE TABLE IF NOT EXISTS state (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
code VARCHAR(6) NOT NULL,
name VARCHAR(50) NOT NULL,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC),
UNIQUE INDEX code_UNIQUE (code ASC)
) ENGINE = InnoDB;
INSERT INTO state (id, code, name) VALUES (null, 'MX-CMX', 'Mexican Federal District');
INSERT INTO state (id, code, name) VALUES (null, 'MX-AGU', 'Aguascalientes');
INSERT INTO state (id, code, name) VALUES (null, 'MX-BCN', 'Baja California');
INSERT INTO state (id, code, name) VALUES (null, 'MX-BCS', 'Baja California Sur');
INSERT INTO state (id, code, name) VALUES (null, 'MX-CAM', 'Campeche');
INSERT INTO state (id, code, name) VALUES (null, 'MX-COA', 'Coahuila');
INSERT INTO state (id, code, name) VALUES (null, 'MX-COL', 'Colima');
INSERT INTO state (id, code, name) VALUES (null, 'MX-CHP', 'Chiapas');
INSERT INTO state (id, code, name) VALUES (null, 'MX-CHH', 'Chihuahua');
INSERT INTO state (id, code, name) VALUES (null, 'MX-DUR', 'Durango');
INSERT INTO state (id, code, name) VALUES (null, 'MX-GUA', 'Guanajuato');
INSERT INTO state (id, code, name) VALUES (null, 'MX-GRO', 'Guerrero');
INSERT INTO state (id, code, name) VALUES (null, 'MX-HID', 'Hidalgo');
INSERT INTO state (id, code, name) VALUES (null, 'MX-JAL', 'Jalisco');
INSERT INTO state (id, code, name) VALUES (null, 'MX-MEX', 'México');
INSERT INTO state (id, code, name) VALUES (null, 'MX-MIC', 'Michoacán');
INSERT INTO state (id, code, name) VALUES (null, 'MX-MOR', 'Morelos');
INSERT INTO state (id, code, name) VALUES (null, 'MX-NAY', 'Nayarit');
INSERT INTO state (id, code, name) VALUES (null, 'MX-NLE', 'Nuevo León');
INSERT INTO state (id, code, name) VALUES (null, 'MX-OAX', 'Oaxaca');
INSERT INTO state (id, code, name) VALUES (null, 'MX-PUE', 'Puebla');
INSERT INTO state (id, code, name) VALUES (null, 'MX-QUE', 'Querétaro');
INSERT INTO state (id, code, name) VALUES (null, 'MX-ROO', 'Quintana Roo');
INSERT INTO state (id, code, name) VALUES (null, 'MX-SLP', 'San Luis Potosí');
INSERT INTO state (id, code, name) VALUES (null, 'MX-SIN', 'Sinaloa');
INSERT INTO state (id, code, name) VALUES (null, 'MX-SON', 'Sonora');
INSERT INTO state (id, code, name) VALUES (null, 'MX-TAB', 'Tabasco');
INSERT INTO state (id, code, name) VALUES (null, 'MX-TAM', 'Tamaulipas');
INSERT INTO state (id, code, name) VALUES (null, 'MX-TLA', 'Tlaxcala');
INSERT INTO state (id, code, name) VALUES (null, 'MX-VER', 'Veracruz');
INSERT INTO state (id, code, name) VALUES (null, 'MX-YUC', 'Yucatán');
INSERT INTO state (id, code, name) VALUES (null, 'MX-ZAC', 'Zacatecas');
List of states: XML
<!-- ISO-3166-2 code + name -->
<?xml version="1.0" encoding="UTF-8"?>
<states>
<state>
<code>MX-CMX</code>
<name>Mexican Federal District</name>
</state>
<state>
<code>MX-AGU</code>
<name>Aguascalientes</name>
</state>
<state>
<code>MX-BCN</code>
<name>Baja California</name>
</state>
<state>
<code>MX-BCS</code>
<name>Baja California Sur</name>
</state>
<state>
<code>MX-CAM</code>
<name>Campeche</name>
</state>
<state>
<code>MX-COA</code>
<name>Coahuila</name>
</state>
<state>
<code>MX-COL</code>
<name>Colima</name>
</state>
<state>
<code>MX-CHP</code>
<name>Chiapas</name>
</state>
<state>
<code>MX-CHH</code>
<name>Chihuahua</name>
</state>
<state>
<code>MX-DUR</code>
<name>Durango</name>
</state>
<state>
<code>MX-GUA</code>
<name>Guanajuato</name>
</state>
<state>
<code>MX-GRO</code>
<name>Guerrero</name>
</state>
<state>
<code>MX-HID</code>
<name>Hidalgo</name>
</state>
<state>
<code>MX-JAL</code>
<name>Jalisco</name>
</state>
<state>
<code>MX-MEX</code>
<name>México</name>
</state>
<state>
<code>MX-MIC</code>
<name>Michoacán</name>
</state>
<state>
<code>MX-MOR</code>
<name>Morelos</name>
</state>
<state>
<code>MX-NAY</code>
<name>Nayarit</name>
</state>
<state>
<code>MX-NLE</code>
<name>Nuevo León</name>
</state>
<state>
<code>MX-OAX</code>
<name>Oaxaca</name>
</state>
<state>
<code>MX-PUE</code>
<name>Puebla</name>
</state>
<state>
<code>MX-QUE</code>
<name>Querétaro</name>
</state>
<state>
<code>MX-ROO</code>
<name>Quintana Roo</name>
</state>
<state>
<code>MX-SLP</code>
<name>San Luis Potosí</name>
</state>
<state>
<code>MX-SIN</code>
<name>Sinaloa</name>
</state>
<state>
<code>MX-SON</code>
<name>Sonora</name>
</state>
<state>
<code>MX-TAB</code>
<name>Tabasco</name>
</state>
<state>
<code>MX-TAM</code>
<name>Tamaulipas</name>
</state>
<state>
<code>MX-TLA</code>
<name>Tlaxcala</name>
</state>
<state>
<code>MX-VER</code>
<name>Veracruz</name>
</state>
<state>
<code>MX-YUC</code>
<name>Yucatán</name>
</state>
<state>
<code>MX-ZAC</code>
<name>Zacatecas</name>
</state>
</states>