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 Link to comment https://forums.phpfreaks.com/topic/36387-formatting-mktime/ 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"); Link to comment https://forums.phpfreaks.com/topic/36387-formatting-mktime/#findComment-173078 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? Link to comment https://forums.phpfreaks.com/topic/36387-formatting-mktime/#findComment-173152 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. Link to comment https://forums.phpfreaks.com/topic/36387-formatting-mktime/#findComment-173155 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? Link to comment https://forums.phpfreaks.com/topic/36387-formatting-mktime/#findComment-173158 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); Link to comment https://forums.phpfreaks.com/topic/36387-formatting-mktime/#findComment-173164 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 Link to comment https://forums.phpfreaks.com/topic/36387-formatting-mktime/#findComment-173175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.