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

181
Views
Transport date and time between Javascript and C#

I'm developing an application which deals with date and time in frontend, with Javascript's Date object, and sends this information to the API based on C#... So far I'm thinking about converting the date and time selected by the user in the frontend using the getTime() function, so I can get its milliseconds and then convert to DateTime in C# with the following function

 public static DateTime GetDateFromMilliseconds(double unixTimeStamp)
    { 
        System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
        dtDateTime = dtDateTime.AddMilliseconds(unixTimeStamp).ToLocalTime();
        return dtDateTime;
    }

So, I'd like to know, is there another better way to deal with it?

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

0

Newer versions of C# include methods for working with Unix timestamps. For this case, using DateTimeOffset.FromUnixTimeMilliseconds() will save you a few lines of code.

Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset.fromunixtimemilliseconds?view=net-5.0

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!