gish Posted February 5, 2009 Share Posted February 5, 2009 hi php freaks How do I get the date function to echo its contents and how do I get a date function to echo out the same contents but one month in advance? thanks gishaust Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/ Share on other sites More sharing options...
Maq Posted February 5, 2009 Share Posted February 5, 2009 What type is your date stored in? date() $next_month = mktime(0, 0, 0, date("m")+1, date("d"), date("y")); echo "Next month is ".date("m/d/y", $next_month); ?> Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-754889 Share on other sites More sharing options...
gish Posted February 5, 2009 Author Share Posted February 5, 2009 Sorry newbie what do yo mean by type? This is what I have so far? echo date(mktime(0,0,0,$m,$y)); echo date(mktime(0,0,0,$m+1,$y)); but looking at what you had. I need to goto php.net and have another look. Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-754894 Share on other sites More sharing options...
gish Posted February 5, 2009 Author Share Posted February 5, 2009 hi me again (0, 0, 0, date("m")+1, date("d"), date("y") is the m, d, y integers Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-754897 Share on other sites More sharing options...
Maq Posted February 5, 2009 Share Posted February 5, 2009 Can you just post your code? If you don't have any, do you want the current time? Input from the user? What? Sorry newbie what do yo mean by type? I meant datatype. Is it a timestamp stored in a DB, a string, integer, what? Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-754908 Share on other sites More sharing options...
gish Posted February 5, 2009 Author Share Posted February 5, 2009 The only code I have is the one I have posted I. All I want to do is print the current date, month, year and if I press a link it goes to the same date, next month, and current year. Thanks of data type information Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-754945 Share on other sites More sharing options...
Maq Posted February 5, 2009 Share Posted February 5, 2009 The only code I have is the one I have posted I. All I want to do is print the current date, month, year and if I press a link it goes to the same date, next month, and current year. Thanks of data type information What format do you want to print the day, month, and year? Here's a list of formats. Current date: $right_now = mktime(0, 0, 0, date("m"), date("d"), date("y")); echo "Current date: ".date("m/d/y", $right_now); ?> I have no clue what you mean by, " if I press a link it goes to the same date, next month, and current year.", or how that even makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-755211 Share on other sites More sharing options...
gish Posted February 6, 2009 Author Share Posted February 6, 2009 I mean some think like this $right_now = mktime(0, 0, 0, date("m"), date("d"), date("y")); echo "Current date: ".date("m/d/y", $right_now); The output would be 6/2/2009 then you press a link <href> Then the output would be 6/3/2009 In Australia is d/m/y Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-755682 Share on other sites More sharing options...
Maq Posted February 6, 2009 Share Posted February 6, 2009 I think this is what you meant. $add = isset($_GET['next']) ? 1 : 0; $right_now = mktime(0, 0, 0, date("m")+$add, date("d"), date("y")); echo "Current date: ".date("d/m/Y", $right_now); ?> Next month Current Date You could also do it easily in JS. Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-755683 Share on other sites More sharing options...
gish Posted February 6, 2009 Author Share Posted February 6, 2009 Thanks that is what I was looking for. One quick question I have been looking at this date function. [mday] => 17 I understand this tells me the day of the month How do I find out how many days that are in a month? Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-755696 Share on other sites More sharing options...
Maq Posted February 6, 2009 Share Posted February 6, 2009 $lastday = mktime(0, 0, 0, 4, -31, 2000); echo strftime("Last day in Feb 2000 is: %d", $lastday); ?> It's all in the manual, mktime. Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-755959 Share on other sites More sharing options...
gish Posted February 7, 2009 Author Share Posted February 7, 2009 thanks Quote Link to comment https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-756524 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.