toString

Formats a Number or Date using the specified format and the current culture.

Example

<script src="https://kendo.cdn.telerik.com/2018.2.620/js/cultures/kendo.culture.de-DE.min.js"></script>
<script>
  // Format a number using standard number formats and default culture (en-US)
  console.log(kendo.toString(10.12, "n"));  // "10.12"
  console.log(kendo.toString(10.12, "n0")); // "10"
  console.log(kendo.toString(10.12, "n5")); // "10.12000"
  console.log(kendo.toString(10.12, "c"));  // "$10.12"
  console.log(kendo.toString(0.12, "p"));   // "12.00 %"

  // Format a number using custom number formats
  console.log(kendo.toString(19.12, "00##")); // "0019"

  // Format a number using standard number format and a specific culture de-DE (default culture is en-US)
  console.log(kendo.toString(10.12, "c", "de-DE")); // "10,12" €

  // Format a date
  console.log(kendo.toString(new Date(2010, 9, 5), "yyyy/MM/dd" ));         // "2010/10/05"
  console.log(kendo.toString(new Date(2010, 9, 5), "dddd MMMM d, yyyy" ));  // "Tuesday October 5, 2010"
  console.log(kendo.toString(new Date(2010, 10, 10, 22, 12), "hh:mm tt" )); // "10:12 PM"
</script>

Returns

String the string representation of the formatted value.

Parameters

value Date|Number

The Date or Number which should be formatted.

format String

The format string which should be used to format the value. Number formatting and date formatting depends on the current culture.

culture String (optional)

The name of the culture which should be used to format the value. The culture should be registered on the page.

In this article
Not finding the help you need?