CanMan2004 Posted January 30, 2007 Share Posted January 30, 2007 Hi allI have a php page which I print todays mktime, the value im left with it something like1167609600It prints this in the url, such as[code]www/checkdate.php?date=1167609600&area=2[/code]How can I convert this so that I can print the month value (ie: 11 for November, 06 for June) and then print the year value (ie: 2007).Can anyone help me? Getting totally stuck on thisThanks in advanceDave Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 30, 2007 Share Posted January 30, 2007 Yes, pass the timestamp into the date function.You can format it, using hte modifiers in this reference on the php manual.http://us2.php.net/manual/en/function.date.phpIt will be $date = date("modification based on that table goes here""timestamp", "modification based on that table goes here"); Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 30, 2007 Author Share Posted January 30, 2007 HelloI have used[code]$newdate = mktime(1170115200 );echo date("Y-m", $newdate);[/code]But it doesnt seem to convert it, any ideas? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 30, 2007 Share Posted January 30, 2007 If you just want to use today's time, you can leave the timestamp part blank.echo date("Y-m-d");to get the current time, do time(), not mktime. Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 30, 2007 Author Share Posted January 30, 2007 Ive got amktimeof1170115200and I want to convert this back intodate("Y-m")Does that help? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 30, 2007 Share Posted January 30, 2007 mktime is not a datatype, so saying you've got a mktime doesn't help, because it doesn't make sense. I think what you have is a timestamp.$timestamp = 1170115200;echo date("Y-m", $timestamp); Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted January 30, 2007 Author Share Posted January 30, 2007 Yes, I was wrong, you were right. Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.