Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
Force date range picker to always display in a chronological order

I have vuetify date range picker

enter image description here

Right now it displays

enter image description here

I would like to force to always display in a lesser date order first for my model.

Ex. 5/1/2022 - 5/14/2022

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can use a computed prop to sort/format the dates, and bind the result to the text field's value:

                         👇
<v-text-field :value="datesText" readonly />
<v-date-picker v-model="dates" range />
export default {
  data: () => ({
    dates: [/* date strings */],
  }),
  computed: {
       👇
    datesText() {
      const dateFormatter = new Intl.DateTimeFormat('en-US')
      return this.dates
        .sort((a, b) => new Date(a) - new Date(b))   // sort chronologically
        .map(d => dateFormatter.format(new Date(d))) // format date in en-US locale
        .join(' - ')
    },
  },
}

demo

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can achieve this by sorting an v-model input value.

Demo :

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    dates: [],
  }),
  computed: {
    dateRangeText () {
      return this.dates.sort().join(', ')
    },
  },
})
<script src="https://unpkg.com/vue@2.x/dist/vue.js"></script>
<script src="https://unpkg.com/vuetify@2.6.6/dist/vuetify.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/vuetify@2.6.6/dist/vuetify.min.css"/>
<div id="app">
  <v-app id="inspire">
    <v-row>
      <v-col
        cols="12"
        sm="6"
      >
        <v-date-picker
          v-model="dates"
          range
        ></v-date-picker>
      </v-col>
      <v-col
        cols="12"
        sm="6"
      >
        <v-text-field
          v-model="dateRangeText"
          label="Date range"
          prepend-icon="mdi-calendar"
          readonly
        ></v-text-field>
        model: {{ dates }}
      </v-col>
    </v-row>
  </v-app>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda