Linto davis
Linto davis

Reputation: 752

how to get the date of first monday of the current year (php)?

how to get the date of first monday of the current year using php functions

example 04-01-2010

Upvotes: 4

Views: 5581

Answers (4)

David Vielhuber
David Vielhuber

Reputation: 3559

<?php
// this does NOT work
echo date('Y-m-d', strtotime('first monday of 2010')); // 2018-12-03

// this does work
echo date('Y-m-d', strtotime('first monday of january 2010')); // 2010-01-04

Upvotes: 1

xenon54th
xenon54th

Reputation: 41

$date = new DateTime('2015-01 monday');

Upvotes: 4

Tam&#225;s Pap
Tam&#225;s Pap

Reputation: 18273

Another possible solution would be:

<?php
echo date("Y-m-d", strtotime("mon jan 2014"));

Upvotes: 2

Psytronic
Psytronic

Reputation: 6113

Just change the format as wanted :)

<php
echo date("d m y", strtotime("first monday of 2010"));
?>

Upvotes: 9

Related Questions