Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

710
Visualizações
how can I get hh:mm time from ISO without any time difference
createAlarm({
    active: true,
    date: picked_Date.toISOString(),
    message: 'sample alarm',
    snooze: 1,
});

I created an alarm using DatePicker(react-native-date-picker), and react-native-simple-alarm

...
<Text>{date}</Text>  // 2022-02-16T08:47:25.352Z

i just want HH : MM value in 24hours, like 13:42, 09:50 or 22:10. so i tried this code

<Text>{moment(date).format('hh:mm')}</Text> // 05:47

This did give me hh:mm formed value, but the value was not the same as my computer and ios simulator it was supposed to 08:47, cause the {date} was 2022-02-16T08:47:25.352Z

How can I get rid of the time difference? and set moment's time zone globally as same as the hardware(simulator or phone)?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

try moment.utc() . it will adjust your input time to UTC so you will the time you want.
also hh:mm will give 12 hour clock time so you will need HH:mm for 24 hour clock

//12 hr clock
var a = moment.utc('2022-02-16T08:47:25.352Z').format('hh:mm');
var b = moment.utc('2022-02-16T18:47:25.352Z').format('hh:mm');

console.log(a)
console.log(b)


//24 hr clock
var c = moment.utc('2022-02-16T08:47:25.352Z').format('HH:mm');
var d = moment.utc('2022-02-16T18:47:25.352Z').format('HH:mm');

console.log(c)
console.log(d)
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.2.1/moment.min.js"></script>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda