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

    How would I get a formatted date without the local timezone offset?

    Framework
    2
    4
    801
    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.
    • T
      toymachiner62 last edited by

      I’m trying to create a filter which would return a formatted date without being calculated with my computers local timezone offset. I have the function below and what it produces, but i’m not sure how to accomplish what i’m looking to do.

      import { date } from ‘quasar’

      export function ciiFormatDate (dt, format = 'MMM DD, YYYY') {
        console.log('---------------')
        console.log('dt = ', dt)
        console.log('formatted dt = ', date.formatDate(dt, format))
        console.log('---------------')
        console.log('newdt = ', new Date(dt))
        console.log('formatted newdt = ', date.formatDate(new Date(dt), format))
        console.log('---------------')
        console.log('new date = ', new Date(dt).toUTCString())
        console.log('formatted new date = ', date.formatDate(new Date(dt).toUTCString(), format))
      }
      

      produces:

      ---------------
      dt =  2018-09-14T02:33:00.000Z
      formatted dt =  Sep 13, 2018
      ---------------
      newdt =  Thu Sep 13 2018 19:33:00 GMT-0700 (Pacific Daylight Time)
      formatted newdt =  Sep 13, 2018
      ---------------
      new date =  Fri, 14 Sep 2018 02:33:00 GMT
      formatted new date =  Sep 13, 2018 <-- TRYING TO GE THIS TO SHOW Sep 14th
      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        If the date you have to give to your function is ZULU to begin with, why convert to ZULU again?

        Just stick the date you have into the formatDate function. Then you get your date as needed. 😄

        (And I am hoping I understand your problem…😊 ) If not, please expand this fiddle.

        https://jsfiddle.net/yaghf3q4/1/

        Scott

        1 Reply Last reply Reply Quote 0
        • T
          toymachiner62 last edited by toymachiner62

          Using Zulu doesn’t work if i’m sitting in -7 GMT.

          See the first part of the output:


          dt = 2018-09-14T02:33:00.000Z <-- Sep 14
          formatted dt = Sep 13, 2018 <-- Sep 13

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by

            So, I guess I’m confused as to what the final goal is. Can you try to clarify some more please?

            Scott

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