Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
Vue-moment showing wrong time with timezone set

Not sure what I am doing wrong. I have a laravel 8 application where I am storing my time in UTC with timestamp_no_timezone in postgresql. When I view the time in the database it is showing today's date with 13:45 as the time. When I use vue-moment and display the time with the timezone set to America/New_York it is still showing 1:45 PM and it should be 8:45 AM with the offset. What could I be missing? I have even done a console.log of the timezone from moment and it is showing America/New_York.

This is the expression that I am using:

{{ [ timesheet.start, "YYYY-MM-DD HH:mm:ss" ] | moment("timezone", "America/New_York", "h:mm A") }}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Convert the stored dateTime to epoch while sending in response.

How you can convert dateTime to epoch there are many ways(send dateTime in epoch in response).

Add in your Model

protected $casts = ['datetime_field' => 'timestamp']

add this method in Laravel class from where you are sending response

    protected function toEpoch($datetime )
    {
        if (gettype($datetime) == 'string') {
            $datetime = new DateTime($datetime);
            return Carbon::instance($datetime)->format('U');
        } else if ($datetime instanceof Carbon) {
            return $datetime->format('U');
        } else if ($datetime != null) {
            return Carbon::instance($datetime)->format('U');
        }
      } 
    }

In vue project

{{new Date(epoch*1000)}}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!