Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I just need some general ideas on how I could do this.

I am working on a community events script. The way the boss wants it organized is with the twelve months on the side, the user clicks on the month, and it displays the closest events first, and any past events are deleted.

I think the easy way to do this would be to have various pull down menus when the user submits an event. Remember, that users can only post events for future dates only. I want a pull down menu for the 12 months, one for the days of the month, and one for years. I'm not sure how I should restrict the user from submitting past events.. just not let them show up in the pulldown menu, or have an error page saying "you choose a past date" or something like that.

But really, the thing I don't understand how to do, would be how to relate to the date selected by the user and to the date on the server. Because, i want to make sure that whenever someone runs the script at a later date, if any postings are older than the current date, i want to delete them. I don't know how I could go about doing this, and how I could compensate for leep years and all of that fun stuff.

Could someone point me in the direction of some helpfull functions, or tutorials, or something that might be of use to me. Because I've never worked this much with dates, and I'm a little scared. Heh.

Thanks monks.

Replies are listed 'Best First'.
Re: Using dates
by azatoth (Curate) on Jun 14, 2001 at 18:39 UTC
Re: Using dates
by Desdinova (Friar) on Jun 14, 2001 at 20:20 UTC
    A few tips i can think off the top of my head..
    1. Don't trust the browser to give valid data. You can restrict when is offered in the dropdowns to simplifiy things for the users but always verify user input.
    2. Store the date in unix time format. This will be easy to compare, sort, and convert to human readable using localtime as for converting human readble dates to unix tim check out Time::ParseDate
    3. Of cousre all of the usual stuff about using strict, -w, and taint mode.
    Hope this helps you out.