Page 1 of 1

Using date, mktime and strotime

Posted: Fri Mar 02, 2007 1:21 pm
by methos
I'm trying to output day 1 of the current month but cannot quite grasp it. According to php.net for mktime: "Arguments may be left out in order from right to left; any arguments thus omitted will be set to the current value according to the local date and time." so why doesn't it output the current month and year correctly???

Code: Select all

date("D, d M Y H:i:s" , mktime(9,30,45, date("M"),1, date("Y")))
date("D, d M Y H:i:s" , mktime(9,30,45,0,1,0))
date("D, d M Y H:i:s", strtotime("+0 month", strtotime("2006-11-01 09:30:45")))
These 3 output this:

Fri, 01 Dec 2006 09:30:45
Wed, 01 Dec 1999 09:30:45
Wed, 01 Nov 2006 09:30:45

Posted: Fri Mar 02, 2007 1:46 pm
by RobertGonzalez
Try

Code: Select all

<?php
$date = date('D, d M Y H:i:s', mktime(0, 0, 0, date('n'), 1, date('Y')));
?>