JavaScript Dates

//* DATE
let currentYear = new Date().getFullYear().toString()
let currentMonth = (new Date().getMonth() +1).toString()
let currentDay = new Date().getDate().toString()
currentMonth.length == 1 ? currentMonth = '0'+currentMonth : currentMonth = currentMonth.toString()
currentDay.length == 1 ? currentDay = '0'+currentDay : currentDay = currentDay.toString()
let yyyymmddToday = [currentYear, currentMonth, currentDay].join("-");
console.log('yyyymmddToday', yyyymmddToday);




// Get date
let date = new Date();

// Format variable named 'date' as MM/DD/YYYY
formatDateMDY() {
  return (
    this.date.slice(0, 10).split("-")[1] +
    "/" +
    this.date.slice(0, 10).split("-")[2] +
    "/" +
    this.date.slice(0, 10).split("-")[0]
    );
   },


// Get today's date in the default format string: '2020-10-11T00:00:00+05:30'
let date = new Date();

// Format as MM/DD/YYYY
let monthDateYear = ((date.getMonth() > 8) ? (date.getMonth() + 1) : ('0' + (date.getMonth() + 1))) + '/' + ((date.getDate() > 9) ? date.getDate() : ('0' + date.getDate())) + '/' + date.getFullYear();
console.log(monthDateYear)

// Pad Numbers (as seen in UnixIsoDate)
let zeroFill = ( number, width ) => {
  width -= number.toString().length;
  if ( width > 0 )
  {
    return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;
  }
  return number + ""; // always return a string
}

// Unix date to ISO
let unixToIsoDate = (unixDate) => {
  let month = new Date(unixDate * 1000).getUTCDate()
  let day = new Date(unixDate * 1000).getUTCMonth()
  let year = new Date(unixDate * 1000).getUTCFullYear()
  // YYYY-MM-DD: return [year, zeroFill(month,2), zeroFill(day,2)].join('-')
  // m/d/y: return [month, day, year].join('/')
}

Similiar Collections

Python strftime reference pandas.Period.strftime python - Formatting Quarter time in pandas columns - Stack Overflow python - Pandas: Change day - Stack Overflow python - Check if multiple columns exist in a df - Stack Overflow Pandas DataFrame apply() - sending arguments examples python - How to filter a dataframe of dates by a particular month/day? - Stack Overflow python - replace a value in the entire pandas data frame - Stack Overflow python - Replacing blank values (white space) with NaN in pandas - Stack Overflow python - get list from pandas dataframe column - Stack Overflow python - How to drop rows of Pandas DataFrame whose value in a certain column is NaN - Stack Overflow python - How to drop rows of Pandas DataFrame whose value in a certain column is NaN - Stack Overflow python - How to lowercase a pandas dataframe string column if it has missing values? - Stack Overflow How to Convert Integers to Strings in Pandas DataFrame - Data to Fish How to Convert Integers to Strings in Pandas DataFrame - Data to Fish create a dictionary of two pandas Dataframe columns? - Stack Overflow python - ValueError: No axis named node2 for object type <class 'pandas.core.frame.DataFrame'> - Stack Overflow Python Pandas iterate over rows and access column names - Stack Overflow python - Creating dataframe from a dictionary where entries have different lengths - Stack Overflow python - Deleting DataFrame row in Pandas based on column value - Stack Overflow python - How to check if a column exists in Pandas - Stack Overflow python - Import pandas dataframe column as string not int - Stack Overflow