Intl

by NativeScript Team

Provides API for using Native date, time and number formatting with an API similar to Intl.js

Welcome to the nativescript-intl plugin for NativeScript framework

Prerequisites

Install nativescript-intl plugin.

Navigate to project folder and run NativeScript-CLI command tns plugin add nativescript-intl.

This plugin provides similar to Intl.js API for date, time and number formatting on a mobile device (Android and iOS).

How to use

var intl = require("nativescript-intl");
var dateFormat = new intl.DateTimeFormat('en-US', {'year': 'numeric', 'month': 'short', 'day': 'numeric'}).format(new Date(2016, 2, 23));
var numberFormat = new intl.NumberFormat('en-US', {'style': 'currency', 'currency': 'USD', 'currencyDisplay': 'symbol'}).format(123456.789);
 
console.log("dateFormat: " + dateFormat);
console.log("numberFormat: " + numberFormat);
// prints Mar 23, 2016
// $123456.79

Since localization formatting is not exactly same on Android, iOS and Intl.js there is another option to use this API.