Source

utils/preparedDate.js

/**
 * Custom hook to format a date string.
 *
 * @param {string} date - The input date string.
 * @returns {string} The formatted date string in "YYYY/MM/DD" format.
 */
export const useDate = (date) => {
  let originalDate = new Date(date);
  // Extract year, month, and day components
  var year = originalDate.getFullYear();
  var month = String(originalDate.getMonth() + 1).padStart(2, "0"); // Month is zero-indexed
  var day = String(originalDate.getDate()).padStart(2, "0");
  // Create the formatted date string
  var formattedDate = year + "/" + month + "/" + day;
  return formattedDate;
};