Having problems with dates

  • Hello,

    I am using Quasar V1.
    I have been having a few problems with dates and would like to know if anyone has experienced the same issue before.

    Based on the import { date } from 'quasar';

    I should be able to do this:

    <q-date v-model="date" mask="DD-MM-YYYYTHH:mm:ss.SSSZ"/>


    let timeStamp = date.formatDate(Date.now(), 'DD-MM-YYYYTHH:mm:ss.SSSZ'); // This is for the user visual

    Which should give me a date with a time.

    My hope was to then have this time converted to Unix with:

    let unixDate = parseInt(date.formatDate(timeStamp, 'X')); // This is for my actions calculations.

    My first problem is that the UNIX time when reconverted back with an online Unix convertor, it gives me a totally different date/month than the initial date.

    My second issue is that after I reconvert this time to Unix, I would like to have a 24 hours span from that time(backward).

    Ie: if right now we are the 4th of sept 2019 time 20:00
    I would like to have
    have the 3rd of sept 2019 time 20:00

    Any idea why I am having the above issues please?

    Thank you.

  • @bambinou You should do something like this:

    // we import all of `date`
    import { date } from 'quasar'
    // destructuring to keep only what is needed
    const { addToDate } = date
    let newDate = addToDate(new Date(), { days: 7, month: 1 })

    You could use days: -1 or hours: -24

Log in to reply