/    Sign up×
Community /Pin to ProfileBookmark

Hi All,

Can someone please explain to me what mktime(0,0,0) in the following code does? Does it meant today at 00:00:00? I am sorry it might be an easy thing but I am a php beginner and I am desperately trying to understand this.

[code=php]<?php
$today = mktime(0, 0, 0);

if(mktime(0, 0, 0, $_POST[‘month’], $_POST[‘day’], $_POST[‘year’]) >= $today)
{
// correct date
}
else
{
// invalid date
}
?> [/code]

thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@fozeratorMay 30.2005 — It checks to see that the entered date is after/during the current day...

Any omitted values in the mktime function default to the current...

You can get quite a bit of info on it at the man page:

http://us3.php.net/manual/en/function.mktime.php

Hope that helps,

James
Copy linkTweet thisAlerts:
@memeauthorMay 30.2005 — Does this mean that mktime(0,0,0) means TODAY at 00:00:00 (midnight hour)? How would I know what the ommitted values are? Have we omitted day, month and year?

I read the manual and it does NOT explain this.

All I need to know is what mktime(0,0,0) means in English.

I really need this urgently.
Copy linkTweet thisAlerts:
@fozeratorMay 30.2005 — Okay... It creates a unix timestamp, which is just an integer value that stores a time value... It creates this based on the date that you enter... You have the following options:

mktime(hour, minute, second, month, day, year)

The omitted values are those that are not explicitly defined... When you enter mktime(0,0,0), you are leaving the month, day and year values undefined, and they will become the current ones... It is the same as saying (for the day of this post) :

mktime(0, 0, 0, 5, 30, 2005)

Since these are integer values, you can perform comparisons and operations on them...

The script is making one variable, $today, become 00:00:00 of the current day... This value is compared against the values entered by the user in a form, and if the values entered are not in the past (or before 00:00:00 of the current day), the script continues saying the date is valid. If not, the date is not valid...

Hope that helps.
Copy linkTweet thisAlerts:
@memeauthorMay 30.2005 — Thanks a million, that is well explained.

Cheers mate ?
×

Success!

Help @meme spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...