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.

Recommended Answers

All 3 Replies

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);
commented: useful +1

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.