0

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:

$nowdate = date('Y') "-" date('Y') + 1;
echo $nowdate;

Thank you for giving time this simple problem.

God bless on this mother earth.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by blocker
Featured Replies
  • 1

    I assume you want $nowdate to be a string. String concatenation in PHP uses a period character to join strings. This **should** work: [code=php] $nowdate = date('Y') . "-" . (date('Y') + 1); [/code] Read More

1

I assume you want $nowdate to be a string. String concatenation in PHP uses a period character to join strings. This **should** work:

$nowdate = date('Y') . "-" . (date('Y') + 1);
Comments
useful
0

This may not be the best way to do it, but it should work

$thisYear = date('Y');
$nextYear = $thisYear + 1
$nowdate = $thisYear "-" $nextYear;

I really need to go to sleep :D

0

This may not be the best way to do it, but it should work

$thisYear = date('Y');
$nextYear = $thisYear + 1
$nowdate = $thisYear "-" $nextYear;

I really need to go to sleep :D

Ive just made a little adjustment of the code you've given and it works. below is the code:

$thisYear = date('Y');
$nextYear = $thisYear + 1;
$nowdate = $thisYear ."-". $nextYear;
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.

This question has already been answered. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.