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

160
Views
checking the ISO data format is not working

I'm trying to check if the 'date-time' string is ISO formatted and I get the following output:

isIsoDate the date string is not ISO format! :  2022-04-21T09:40:01.000Z
isIsoDate converted-back date :  2022-04-21T09:40:01.000Z
isIsoDate time stamp number :  1650534001000
isIsoDate string builded back :  Thu Apr 21 2022 11:40:01 GMT+0200 (Ora legale dell’Europa centrale) 

this is my code:

export function isIsoDate(dateString) {
    
        var dateParsedNum = Date.parse(dateString);
        var dateBackToString = new Date(dateParsedNum);
        var stringBuilded = "";
    
    
        stringBuilded = dateBackToString.toString()
    
    
        if ((dateBackToString.toString()) == dateString) {
            return true;
            
        } else {
           console.debug("isIsoDate() the date string is not ISO format! : ", dateString);
           console.debug("isIsoDate() converted-back date : ", dateBackToString);
           console.debug("isIsoDate() time stamp number : ", dateParsedNum);
           console.debug("isIsoDate() string builded back : ", stringBuilded);
           // throw new BadRequestException('Validation failed');
        }
    
        return(false)
    }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I'm not sure if it can be done with JavaScript's Date utilities. As Salman said in the comments, you can have .toISOString() instead, but this method converts everything into UTC, whereas the ISO specification is more flexible than that.

I recommend this StackOverFlow answer that uses RegEx to validate ISO strings.

about 4 years ago · Juan Pablo Isaza Report

0

did you check the setting? there is several solutions in the site

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!