setting the date of the current year

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

setting the date of the current year

Post by pleigh »

hi, is this correct, when i declare

Code: Select all

date();
, the output will be the date today. if that is correct, how about setting the variable date to something like the start of the year?

for example, i ant to declare the value of $startDate to the first week of the current year

thanks
User avatar
N1gel
Forum Commoner
Posts: 95
Joined: Sun Apr 30, 2006 12:01 pm

Post by N1gel »

date("Y") should give you the current year.

so if you wanted the date off the first day off the year you could try.

Code: Select all

echo "01-01-".date("Y");
its cheap and cheerful but it gives you

01-01-2007
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

hi, thanks for the reply..but i was just wondering how can i integrate the date january 1 on this code

Code: Select all

$x = strtotime("last Monday");
$Year = date("Y",$x);
$Month = date("m",$x);
$Day = date("d",$x);
thanks againd.:)
Post Reply