Is there a way to format a Javascript data into dd-mm-yyyy?

Currently I’m getting a date as from the kendo date-picker as such (1)Sun Feb 01 2021 00:00:00 GMT+0000 (GMT). However, I would like this date to format it in dd/mm/yyyy So I did the below logic to reflect my desired date. The below implementation, returns for instance the following date 26-01/2021 but in a string type. I would like to have a Date object but not in the way stated in the above date [(1)] but something like this 26 01 2021 00:00:00 GMT.

Is this possible?

  public static formatDate(dt: Date): string {
    const isValid = this.isValidDate(dt);
    if (isValid) {
      const formattedDate = dt.toLocaleDateString('en-GB', {
      day: 'numeric', month: 'numeric', year: 'numeric'
      }).replace(/\//g, '-');
      return formattedDate;
    return null;

  public static isValidDate(date) {
    return date && === "[object Date]" && !isNaN(date);

137 thoughts on “Is there a way to format a Javascript data into dd-mm-yyyy?”

  1. My programmer is trying to convince me to move to .net from
    PHP. I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using Movable-type on various websites for about
    a year and am worried about switching to another platform.
    I have heard good things about

    Is there a way I can transfer all my wordpress content into it?
    Any kind of help would be greatly appreciated!


Leave a Comment