date variable plus 1 error(pls help)

Thread Solved

Join Date: Jan 2009
Posts: 125
Reputation: blocker is an unknown quantity at this point 
Solved Threads: 0
blocker's Avatar
blocker blocker is offline Offline
Junior Poster

date variable plus 1 error(pls help)

 
0
  #1
Mar 23rd, 2009
good day.!

I want this date format to be echo. 2009-2010. My code gots error when i try to show this format. Here is my code:
  1. $nowdate = date('Y') "-" date('Y') + 1;
  2. echo $nowdate;

Thank you for giving time this simple problem.

God bless on this mother earth.
Last edited by blocker; Mar 23rd, 2009 at 1:43 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 801
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 110
darkagn's Avatar
darkagn darkagn is offline Offline
Practically a Posting Shark

Re: date variable plus 1 error(pls help)

 
1
  #2
Mar 23rd, 2009
I assume you want $nowdate to be a string. String concatenation in PHP uses a period character to join strings. This **should** work:

  1. $nowdate = date('Y') . "-" . (date('Y') + 1);
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 525
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 86
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: date variable plus 1 error(pls help)

 
0
  #3
Mar 23rd, 2009
This may not be the best way to do it, but it should work
  1. $thisYear = date('Y');
  2. $nextYear = $thisYear + 1
  3. $nowdate = $thisYear "-" $nextYear;
I really need to go to sleep
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 125
Reputation: blocker is an unknown quantity at this point 
Solved Threads: 0
blocker's Avatar
blocker blocker is offline Offline
Junior Poster

Re: date variable plus 1 error(pls help)

 
0
  #4
Mar 23rd, 2009
Originally Posted by xan View Post
This may not be the best way to do it, but it should work
  1. $thisYear = date('Y');
  2. $nextYear = $thisYear + 1
  3. $nowdate = $thisYear "-" $nextYear;
I really need to go to sleep
Ive just made a little adjustment of the code you've given and it works. below is the code:

  1. $thisYear = date('Y');
  2. $nextYear = $thisYear + 1;
  3. $nowdate = $thisYear ."-". $nextYear;
  4. echo $nowdate;

Thank many very much.

The first reply shows nothing on the browser but I use his technique to concantinate the string and echo it.

Thank you to all.
Last edited by blocker; Mar 23rd, 2009 at 2:05 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC