/    Sign up×
Community /Pin to ProfileBookmark

Date () how to match number to name

I have found a lot of info on the Date function, but not on how to make it convert the month name to it’s corresponding number.

What I have is a simple form in which the user chooses the month from the drop down and submits it. (ie, October) I need to know how to convert “October” to the number 10 for use in other date functions so I can get the number of days in the month, etc.. in order to generate a calendar based on the users selection.

Htis is what I have so far:

[CODE]
$monthName = $_POST[‘month’];
$year = $_POST[‘year’];

$monthNum = date(n, mktime(0, 0, 0, $monthName, 1, $year));
$daysInMonth = date(t, mktime(0, 0, 0, $monthName, 1, $year));
[/CODE]

I need to know how to reconcile the month name selction from the drop down to the month number in the mktime function

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@hastxauthorNov 03.2005 — Oh Duhhh!

All I had to do was put the number values to the drop down on the selection form

... <option value=10> October ....

I had a feeling if I asked the question I'd find the answer....I chnged the $monthName variable to $monthNum so it would make more sense in the date functions
×

Success!

Help @hastx 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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