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)
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(10.12, "n"));  // "10.12"
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(10.12, "n0")); // "10"
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(10.12, "n5")); // "10.12000"
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(10.12, "c"));  // "$10.12"
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(0.12, "p"));   // "12.00 %"

  // Format a number using custom number formats
/* The result can be observed in the DevTools(F12) console of the browser. */
  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)
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(10.12, "c", "de-DE")); // "10,12" €

  // Format a date
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(new Date(2010, 9, 5), "yyyy/MM/dd" ));         // "2010/10/05"
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(kendo.toString(new Date(2010, 9, 5), "dddd MMMM d, yyyy" ));  // "Tuesday October 5, 2010"
/* The result can be observed in the DevTools(F12) console of the browser. */
  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? Improve this article