Jump to content

[SOLVED] date function


gish

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-755211
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/143862-solved-date-function/#findComment-755683
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.