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

Max100's avatar

Can I add Tempus Dominus datetime picker to Breeze/Vue with Inertia

I need a datetime picker which is better than the html5 datetime-local, mostly because Firefox doesn't really support it.

Unfortunately, it seems that many of the available options require jquery and bootstrap.

However, It looks like the latest Tempus Dominus datetime picker might be a workable option. It's only needed on a couple of forms, so I'd prefer using the CDN version. But I don't know how to integrate it into my Breeze/Vue app.

Has anyone used this datetime picker with Breeze/Vue? Or are there any recommendations for a datetime picker to use with Breeze/Vue?

Thanks

0 likes
5 replies
LaryAI's avatar
Level 58

Yes, you can add Tempus Dominus datetime picker to Breeze/Vue with Inertia. Here are the steps to do so:

  1. Install Tempus Dominus using the CDN link in your HTML file:
<head>
  ...
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.39.0/css/tempusdominus-bootstrap-4.min.css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.39.0/js/tempusdominus-bootstrap-4.min.js"></script>
</head>
  1. Create a Vue component for the datetime picker:
<template>
  <div>
    <input type="text" class="form-control datetimepicker-input" :id="id" :data-target="#datetimepicker1" data-toggle="datetimepicker" :value="value" @input="$emit('input', $event.target.value)">
  </div>
</template>

<script>
export default {
  props: {
    id: {
      type: String,
      required: true
    },
    value: {
      type: String,
      required: true
    }
  },
  mounted() {
    $(`#${this.id}`).datetimepicker({
      format: 'YYYY-MM-DD HH:mm:ss'
    });
  }
}
</script>
  1. Use the component in your Breeze/Vue app:
<template>
  <div>
    <datetime-picker id="datetimepicker1" v-model="datetime"></datetime-picker>
  </div>
</template>

<script>
import DatetimePicker from './DatetimePicker.vue';

export default {
  components: {
    DatetimePicker
  },
  data() {
    return {
      datetime: ''
    }
  }
}
</script>

That's it! You should now have a working datetime picker in your Breeze/Vue app using Tempus Dominus.

Snapey's avatar
Snapey
Best Answer
Level 122

Add it to the head of your master layout file.

Do you need to interact with Vue? If you just want to decorate an input field, just follow the documentation for the package.

Max100's avatar

No luck yet. Initially, I added the scripts and stylesheet to the head of app.blade.php. Then I copied some code from the Tempus Dominus website into my form. But then the form failed to load and the console listed an error about failing to import the form module itself.

Then I moved the scripts and stylesheet to the very end of the head in app.blade.php. Now the form starts to load, but then fails with an error from the tempus-dominus-min.js, stating that no element was provided.

So, at least the app seems to be seeing the tempus-dominus js file.

The problem is, I've never used this datepicker before, so I don't know how to use it even in a vanilla environment. I guess, I'll start exploring it in a plain html form. After that, I can try using it in Breeze/Vue.

Thanks for your help!

Max100's avatar

@Snapey Quick follow-up.. It turns out the error was because the datepicker script was being called before the dom was ready.

I put the call into the on Mounted() and then everything worked! Fwiw, I also had to add font awesome to get the picker to appear properly.

Thanks a lot for your help!

Please or to participate in this conversation.