m-date-picker icon indicating copy to clipboard operation
m-date-picker copied to clipboard

How to change the Date format "ordering" and how to change the Months and Days formats ?

Open fadighattas100 opened this issue 7 years ago • 5 comments

How can we change the display Date from 'Y M D' to 'M D Y' and how can we use the formatMonth and formatDay please can we give us an example for those noobies like me in react native,

i need to display a date picker like this "April 10 2018"

fadighattas100 avatar Apr 16 '18 18:04 fadighattas100

i manage to change the months form number to names like this

`const months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ];

export function monthNumToName(monthNum) { return months[monthNum - 1] || ''; }`

<DatePicker rootNativeProps={{'data-xx': 'yy'}} defaultDate={now} mode={'date'} locale={enUs} //maxDate={maxDate} //minDate={minDate} onDateChange={()=>{}} onValueChange={()=>{}} onScrollChange={()=>{}} formatMonth={ (month, date) => {return monthNumToName(month+1)}} // use12Hours />

but still i can't change the date format

fadighattas100 avatar Apr 16 '18 18:04 fadighattas100

i just look into the code and noticed that you are no date formation for reordering the way the date is displaying like 'M D Y' and you are using the following way to get the years , months and days

   var _getValueCols = this.getValueCols(),
                value = _getValueCols.value,
                cols = _getValueCols.cols;

i hope you add the ability to change the order of the dates fileds it will be much helpful

fadighattas100 avatar Apr 16 '18 19:04 fadighattas100

For anyone who wants to display date pickers in custom order, like month -> day -> year for example, easy hack is to declare order css property on rmc-picker elements, like so:

.rmc-date-picker {
  & .rmc-picker:nth-child(1) {    
    order: 2;
  }
  & .rmc-picker:nth-child(2) {
    order: 0;
  }
  & .rmc-picker:nth-child(3) {
    order: 1;
  }
}

avinograd0v avatar Feb 02 '19 20:02 avinograd0v

@avinograd0v, where should I write the css? could you tell me the file name?

I am using react native

kurniawanj26 avatar Jan 10 '20 06:01 kurniawanj26

The same issue. How to change the date format order like MM/DD/YYYY?

arlovip avatar Jan 14 '20 09:01 arlovip