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

270
Visualizações
Get day from date Laravel

I got a date with format 'Y-m-d', and want to get the day from it. Like if I have 2021.01.01, I want for example Friday, or Thursday depending on what day it actually is. I already got the date stored as $date and I want the day stored as $day.

I've already tried this, without any error, and without anything happening:

$day = Carbon::createFromFormat('Y-m-d', $date)->format('1');
var_dump($day);
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You can try this ,

$d=unixtojd(mktime(0,0,0,6,20,2007));
var_dump(cal_from_jd($d,CAL_GREGORIAN));

output :

    array (size=9)
  'date' => string '6/20/2007' (length=9)
  'month' => int 6
  'day' => int 20
  'year' => int 2007
  'dow' => int 3
  'abbrevdayname' => string 'Wed' (length=3)
  'dayname' => string 'Wednesday' (length=9)
  'abbrevmonth' => string 'Jun' (length=3)
  'monthname' => string 'June' (length=4)

And for your code , you just need to add your date like this

$d=unixtojd(mktime(0,0,0,month,days,year));
$calendar  = cal_from_jd($d,CAL_GREGORIAN);
var_dump($calendar['dayname']);
over 4 years ago · Santiago Trujillo Relatório

0

I've found another solution for you :

$timestamp = strtotime('2009-10-22');
$day = date('l', $timestamp);
echo $days;

output:

Thursday

over 4 years ago · Santiago Trujillo Relatório

0

It seems like you used a 1 (one) instead of an l (lowercase L). If you change that, it works fine.

$day = Carbon::createFromFormat('Y-m-d', $date)->format('l');
var_dump($day);
over 4 years ago · Santiago Trujillo 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