Help with mktime()
Posted: Sun Apr 27, 2003 3:26 pm
Hi, I need to convert some dates into timestamps, I am using the mktime() funtion.
The code I have tried is as follows:
At first this seemed to work, but on closer inspection it does not work as expected.
If I run the code below after making $timestamp I get
27May2003
1040947200
27 Fri December 2002
30 Sat November 2002
This prints the data used to make the timestamp, then the timestamp itself, then uses the date function to make the date using the timestamp (an error occurs here, the 2 dates don't match) It then prints the current date using the mktime() function, and yet again an error occurs here. Does anybody know what's wrong with this?
If not, could you please explain to me how to get the ordinal suffix for a certain number (eg for 1 it would be st, for 2 it would be nd and for 3 it would be rd, etc) without using a timestamp?
Thanks for any help
David
The code I have tried is as follows:
Code: Select all
<?php
$timestamp = date ("U", mktime( 0,0,0,$_POST[month],$_POST[daynumber],$_POST[year]) );
?>If I run the code below after making $timestamp I get
27May2003
1040947200
27 Fri December 2002
30 Sat November 2002
Code: Select all
<?php
print $_POST[daynumber];
print $_POST[month];
print $_POST[year];
print "<br>";
print $timestamp;
print date( " d D F Y", $timestamp );
print date( " d D F Y ", mktime ( 0,0,0,date("D"),date("F"),date("Y")));
?>If not, could you please explain to me how to get the ordinal suffix for a certain number (eg for 1 it would be st, for 2 it would be nd and for 3 it would be rd, etc) without using a timestamp?
Thanks for any help
David