$y\n"; } } //** ©William Fowler (wmfwlr@cogeco.ca) //** January 26/2004, Version 1.0 //** Tweaked by Steve Gaarder 12/2008 to return -1 for invalid dates //** Get the adjusted timestamp associated with the day, month, and year //** given. Months and days are indexed starting at one (1). Any date before //** January 1, 1970 will be converted to year 1970 (due to 'mktime()' //** limitations). function GetValidDate($month=1, $day=1, $year=1970) { //** provide a default value and convert the day of the month given. Day //** cannot be less than 1 or greater than 31. $valid = 1; if ($day > 31) { $valid = 0; $day = 31; } if ($day < 1) { $valid = 0; $day = 1; } //** provide a default value and convert the month number given. Month cannot //** be less than 1 or greater than 12. if ($month > 12) { $valid = 0; $month = 12; } if ($month < 1) { $valid = 0; $month = 1; } //** handle compensating for day runover if the number of days selected is //** greater than those allowable for the selected month. switch($month) { //** if FEBRUARY the selected day must be corrected and a leap year must be //** acounted for as well. //** CHANGED JAN 26/2004 - corrected for leap year error. case 2 : if($day > 28) { if ($day > 29) { $valid = 0; $day = 29; } if (!($year % 4 == 0 && ($year % 100 != 0 || $year % 400 == 0))) { $valid = 0; $day = 28; } } break; //** only maximum of thirty days in these months. case 4 : //** APRIL case 6 : //** JUNE case 9 : //** SEPTEMBER case 11 : //** NOVEMBER if ($day > 30) { $valid = 0; $day = 30; } break; } //** construct the appropriate date timestamp from the parameters provided. if ($valid) { //** provide a default value and convert the day of the year number given. $year = max(1970, intval($year)); return mktime(0, 0, 0, $month, $day, $year); } else { return (-1); } } ?> Cornell Math Summer Program for Undergraduate Research
Skip to main content

Get new PIN Number

Use this form to get a new PIN emailed to you for an existing account.

If you do not already have an account, please go here to create one.


First Name:
Last/Family Name:

Email Address: