Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda