Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nafeeur10's avatar

daterange to my own styled date

With using daterange I am getting an array of two dates

{{ value[0] }}

It is giving me like this:

Thu Dec 19 2019 00:00:00 GMT+0600 (Bangladesh Standard Time)

But I want to print it in my style. Like

November 26, 2019 and December 26, 2019.

Working with Element: https://element.eleme.io/#/en-US/component/date-picker

0 likes
9 replies
nafeeur10's avatar

@nakov,

January, February, March etc

May be I need to hard code it with Javascript. Here is not solution for it.

Nakov's avatar

@nafeeur10 no you don't need to hard-code it.. You just need the right format: MMMM will give you just that.

You need to add: format="MMMM d, yyyy" on the element.

nafeeur10's avatar

@nakov,

Okay. It is working on daterange input but in output ({{ value[0] }}) it is giving the same as I posted.

Nakov's avatar

@nafeeur10 can you show me how do you get the date from the database? You will have to change the format there too. On the Carbon instance.

nafeeur10's avatar

@nakov

<template>
  <div class="block">
    <p>Component value:{{ value }}</p>
    <el-date-picker
      v-model="value"
      type="daterange"
      start-placeholder="Start date"
      end-placeholder="End date">
    </el-date-picker>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        value: ''
      };
    }
  };
</script>

I am not using database yet. It's from vue.

Nakov's avatar

@nafeeur10 but you've tried adding the format?

<el-date-picker
      v-model="value"
      type="daterange"
      start-placeholder="Start date"
    format="MMMM d, yyyy"
      end-placeholder="End date">
    </el-date-picker>

?

nafeeur10's avatar

@nakov,

Tried with your. But same result in output. After selecting two dates.

Thu Dec 19 2019 00:00:00 GMT+0600
Nakov's avatar

@nafeeur10 every datepicker selector that shows this format, must have this attribute:

format="MMMM d, yyyy"

Otherwise it will show a default value.

Please or to participate in this conversation.