[Vuejs]-How to put a converted date (to a given timezone) in a v-model in order to send such to the backend?

0👍

Try to call you toTimeZone function before sending data to backed.

So your template:

<md-input type='datetime-local' v-model='campaign.scheduled_date'></md-input>

And your script:

...
data() {
  return {
    campaign: {
      scheduled_date: '' 
    }
  }
},
methods: {
 toTimeZone(time) {
   return moment(time).tz("America/Bogota").format();
 },
 sendToAPI() {
   this.campaign.sheduled_date = this.toTimeZone(this.campaign.sheduled_date)
   this.$api.post(this.campaign)
 }
}
...

Leave a comment