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
Share on other sites

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

Link to comment
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
Share on other sites

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.