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

225
Visualizações
Const that returns a value depending on another value

This is the Function that Determined the current Date and Time

var min = new Date().getMinutes(); //To get the Current Minutes
var hours = new Date().getHours(); //To get the Current Hours

var date = new Date().getDate(); //To get the Current Date
var month = new Date().getMonth() + 1; //To get the Current Month
var year = new Date().getFullYear(); //To get the Current Year

This is where the Const with the If Statement i

const monthInLetters = (month) => {


if (month== '3'){ return ('January')}

  
};

And then it gets rendered in this Text box

<Text style={{color: 'white' fontSize: 40}}>{date}, {month} {monthInLetters}, {year}</Text>

I want it to check the month of the year in numbers and then convert that to the month as a string? How would I do that?

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

0

You don't need to "check the month of the year in numbers and then convert that to the month as a string" - you can just use toLocaleString, e.g.

const date = new Date();
const month = date.toLocaleString('default', { month: 'long' });
console.log(month);

Also there is no need to create a new date object for each part of the date. e.g.

var date = new Date()

var min = date.getMinutes(); //To get the Current Minutes
var hours = date.getHours(); //To get the Current Hours
var date = date.getDate(); //To get the Current Date
var month = date.getMonth() + 1; //To get the Current Month
var year = date.getFullYear(); //To get the Current Year
about 4 years ago · Juan Pablo Isaza Relatório

0

Answering as you said it doesn't work

const monthInLetters = (month) => {
  let months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
      return months[month - 1];
};
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