mktime

how to get the correct timestamp with the is_dst parameter in PHP?

We are creating a unix timestamp with the mktime method giving following attributes: print_r(mktime(0,0,0,3,1,2009)); print_r(mktime(null,null,null,3,1,2009) / 60 / 60 / 24) . "days");` this creates a result of 1235862000 14303.958333333 days this should be 14304 days. The problem in this case is the winter hour. You can use the i...

How would I fix the last day of the month errors that result with this php code?

Hello, The code below is what I'm using for a website menu which moves the link for the current month's page to the top of the link list on the change of the month. But this fails on the 31st of some months, such as April; I get two links to the same month for most of the links. I've read through the issues with the way php generates da...

Problems formating a date

I am trying to write a function to format a date and time for me. I have an almost identical function which formats just a date. That function works fine. I just added some code to try and have it format the date with a time. It should return something like "May 18, 2009 9:50 PM" but I am getting this warning: Warning: mktime() expects ...

convert mysql timestamp to mktime

Hi, I have the following MySQL timestamp: 2009-06-23 16:21:48 How can I convert it to a format like mktime()? ...

MKTime Function Returning Wrong Time?

Hi guys, I'm having a bit of trouble with the mktime function. On my production server, if I execute the following: echo '<p>' . mktime(24, 0,0, 8,29,2009) . ' - 12pm</p>'; echo '<p>' . mktime(23, 0,0, 8,29,2009) . ' - 11pm</p>'; echo '<p>' . mktime(22, 0,0, 8,29,2009) . ' - 10pm</p>'; And then convert those timestamps back to readabl...

PHP swap month and day in timestamp

Hey Guys, Right. I was inserting a load of data into a MySQL DB and used the following to generate the timestamp: $stamp = mktime($t[0], $t[1], $t[2], $d[2], $d[1], $d[0]); Unfortunately, the day and month were mixed around, and below is the correct timestamp. $stamp = mktime($t[0], $t[1], $t[2], $d[1], $d[2], $d[0]); It is about ...

Odd behavior of mktime()

Continuing on my attempt to create a DateTime class , I am trying to store the "epoch" time in my function: void DateTime::processComponents(int month, int day, int year, int hour, int minute, int second) { struct tm time; time.tm_hour = hour; time.tm_min = minute; time.tm_sec = second; ...

Time of day script

Hi all, I have a small script that depending on the time and day; I would like it to output different things: <?php $currenttime = ((date("H")+7). ":" .date("i")); if ($currenttime >= "16:30") { $tomorrow = mktime(0, 0, 0, date("m") , date("d")+2, date("Y")); $jsdate = (date("Y"). "-" .date("m"). "-" .(date("d")+1). ...

php - mktime or strtotime?

I'm trying to convert 2010-02 to February, 2010. But, I keep getting December, 1969 I've tried using mktime, strtotime, and some combination of the two, but still haven't been able to do it... This is what I tried most recently... $path_title = date('F, Y', mktime(0,0,0,2,0,2010)); ...

Better way of creating a PHP future date

Is there a quicker way of creating a date such as: echo date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")+3, date("Y"))); Thanks if you can help. ...

is mktime() using date() daylight saving aware?

I've read through a few questions about this here on s.o. and none seem to ask or answer the question very bluntly: $ts_today = mktime( 0, 0, 0, date('m'), date('d'), date('Y') ); is this daylight saving aware? if not, how do i make mktime() daylight saving aware? ...

In PHP given a month string such as "November" how can I return 11 without using a 12 part switch statement?

I.e. Month Returns January 1 February 2 March 3 April 4 May 5 June 6 July 7 August 8 September 9 October 10 November 11 December 12 I've seen examples using mktime when given the number of the month and returning the month string, but not the reverse. ...

MKTIME, PHP date/timestamp YYYY-MM-DD

I need to query MySQL for the current date (from PHP) in YYYY-MM-DD format... anyone? ...

Opposite of mktime() in php?

How could I convert a unix timestamp , i.e. from time(), into a m-d-Y string using php? ...

mktime() expects parameter 1 to be long string given

how can i solve the warning in my page like mktime() expects parameter 1 to be long string given.. Here is my code $next = date("Y-m-d H:i:s", mktime($t_parts[0],$t_parts[1],$t_parts[2],$d_parts[1],$d_parts[2],$d_parts[0])); ...

why strotime returns negative value in php?

Hi, I am using strtotime to convert a date to a unixtime stamp. Year, date and day comes as different values to code and I am using the below code to produce the timestamp. $year = '1961'; $month = '2'; $day = '15'; $date = $year."-".$month."-".$day; echo strtotime($date); The above code prints : -27648000 for me. If the year ...

php mktime for epoch returns -3600, not 0

Hi If I run the following in PHP: echo mktime(0,0,0,1,1,1970); the returned value is -3600, not 0 as I expected. The server is UK based, it's currently 21 Sep (i.e. BST summertime) (though I wouldn't expect this to affect the epoch timestamp) and per php.info: "Default timezone Europe/London". Setting the daylight saving time fl...

Countdown timer not working correctly

I'm working on a countdown timer for my website, but can't get the script to work. The creator of the script, PHP F1, hasn't been able to help with it. Question is: Why is the year in the target date ($targetDate) variable not making it through to the HTML/JavaScript implement? I'm using the mktime() function. No matter whether I put t...

PHP Date/Time and mktime

Hopefully someone can tell me whats going on with this little debugging script. <?PHP // function generates the list of times for function generateTimes($date) { $currentDate = $date; echo "RECEIVED CURRENT DATE: " . date("m/d/Y g:iA", $currentDate) . "<br /><br />"; for($i = 0; $i < 48; $i++) { echo date("g:iA", $currentDat...

How can I use PHP to list all the dates in a year?

Hi, I'm trying to use PHP to create a script that searches all the days between now and one year's time and lists all the dates for Fridays and Saturdays. I was trying to use PHP's date() and mktime() functions but can't think of a way of doing this. Is it possible? Thanks, Ben ...