No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Having problems with dates

    Help
    2
    2
    155
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bambinou last edited by bambinou

      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"/>
      

      OR

      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.

      1 Reply Last reply Reply Quote 0
      • Hawkeye64
        Hawkeye64 last edited by

        @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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post