Skip to content

Commit

Permalink
Add convert date
Browse files Browse the repository at this point in the history
  • Loading branch information
kekefreedog committed Feb 2, 2024
1 parent cc24fec commit 9449bc0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Front/Library/Utility/DateTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,34 @@ export default class DateTime {
return `${year}${month}${day}`;
}

/**
* Convert Date Fromat
*
* To D/M/YYYY
*
* @param dateStr
* @returns
*/
public static convertDateFormat = (dateStr:string):string => {

// Set result
let result = "";

// Check date
if(!dateStr)

// Return result
return result;

// Parse the input string into a Date object
const date = new Date(dateStr);

// Format the date as D/M/YYYY
// Note: getMonth() returns 0 for January, 1 for February, etc., so we add 1.
result = `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()}`;

// Return result
return result;
}

}

0 comments on commit 9449bc0

Please sign in to comment.