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

265
Views
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 answers
Answer question

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 Report

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 Report

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 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!