Nepali DateNepali DateBikram Sambat Date Engine
Methods

date.toString()

Return the default string representation of a NepaliDate instance in standard year, month, and day format.

The toString method converts the NepaliDate instance into a standard readable date string formatted as year, month, and day separated by forward slashes. It provides a simple default serialization format suitable for logs and quick display.


Import

import { NepaliDate } from "nepali-date-library";

Signature

toString(): string;

Parameters

This method does not take any parameters.


Return Value

  • Type: string
  • Returns the date formatted as ${year}/${month + 1}/${day} where month is 1-indexed.

Examples

Default Serialization

import { NepaliDate } from "nepali-date-library";

// 2081 Baisakh 15 (month index 0)
const date = new NepaliDate(2081, 0, 15);

console.log(date.toString()); // "2081/1/15"
console.log(String(date));    // "2081/1/15"

String Interpolation

import { NepaliDate } from "nepali-date-library";

const date = new NepaliDate("2081-10-25");
console.log(`Nepali Date: ${date}`); // "Nepali Date: 2081/10/25"

Advertisement

On this page