Browse | Submit A New Snippet
Snippets by category: Calendars/Dates
| Snippet ID | Title | Creator |
| Snippets | ||
| 133 | Calender Classes | jimwright |
| Contains a core class with no visual interface for use by you in your scripts AND a HTML interface class that will use the core class to display a one month calender with drop down month & year selector, next/previous month buttons, dates displayed are clickable and highlightable. Currently it doesn't look so great in netscape so I would appreciate any assistance with that. | ||
| 615 | Human readable date in Spanish | jcgonz |
| This simple function will return the actual date in a human readable way in Spanish. | ||
| 22 | Simple Calendar | esadler |
| Just a very simple calendar program, but you can edit it so it actually does something useful. | ||
| 66 | Calendar w/ links to data from db | inferno |
| This calendar is fully configurable and features the ability to link to data from a MySQL server. You can set the colors, table/row/cell tags (like padding and spacing) as well as a ton of other options. There are a lot of comments, making is easy to modify. | ||
| 32 | Time left | mcrbids |
| returns time left in english when you give seconds. time_left(45) returns "45 seconds." time_left(70) returns "1 minute 10 seconds." | ||
| 1262 | Intelligent Date Selector | jurowski |
| From: Sandon Jurowski At: UW Madison Medical School jurowski@wisc.edu /> Here is a feature-rich, html-generating, 3-column date-picker class that: a) automatically selects a the correct pulldown values from a mysql record field in the "date" format of "0000-00-00". b) re-selects the previously or newly chosen values if the form is re-sent (as during data validation errors) c) lets you choose a default date, or today's date as the default d) lets you choose the minimum and maximum year values OR lets you choose a difference value for the minumum and for the maximum as well when populating the year pulldown | ||
| 48 | Really simple calendar | superfudge |
| Really simple calendar generator, it makes a calendar 3 months across and 4 down. Embedded within are 2 functions - one makes each month, and the other just loops through all the months. This is a PHP4 script, but it should be fairly simple to convert to PHP3 (hint: You'd have to initialize $sequence differently). There's no comments, but it should be pretty obvious as to how it works, especially after reading up on the getdate() PHP function. License restricted to the use for the forces of good only. See an example at http://www.superfudge.com/calendar.php | ||
| 92 | Date Conversion | swativ |
| Convert MYSQL date (yyy-mm-dd) to date like mm/dd/yyy | ||
| 99 | Today_PHP | markmh84 |
| Put todays date and/or time on your web site with this easy to configure and install script. | ||
| 1341 | VCalendar | webinventor |
| VCalendar (Virtual Calendar) is an open source Web calendar application with related tools, for posting and maintaining events and schedules online, in calendar format. VCalendar comes with source code in multiple programming languages: PHP, ASP and ASP.NET (C# and VB.NET); with potential for adding more technologies in the future. | ||
| 1309 | OpenBookings.org | jroger |
| Openbookings.org is an online booking software that allows to manage in an unified way the timetables of all the shared resources of your group, association or company (vehicles, conference rooms, computers, video projectors, cameras, ...). | ||
| 1294 | Calendar Class | konstantin_17 |
| Simple class with clear and documented code, which will help you to both to understand the algorithm of the building the calendar and use this idea in your application. | ||
| 160 | phpCalendar | swdzchef |
| This is a simple calendar that displays a nice, attractive calendar with month forward and backward buttons (you supply icons). | ||
| 161 | phpCalendar2 | swdzchef |
| This is another simple calendar but listed again because now it includes minimal database support (PostgreSQL). Gives month and day views. | ||
| 173 | Date Select Object | ujludwig |
| This is 2 date functions. The first creates a date object, the second processes the data on submit. | ||
| 174 | Splitting MySQL timestamp into separate variables | igork |
| Splitting MySQL timestamp into separate variables | ||
| 186 | NextDay | morphy |
| u have a date and want to know the next day i used it for loops..... | ||
| 187 | Date/Time Count Down | tom_g |
| PHP Count down days:hours:minutes:seconds between current date/time and future date/time. I'm a newbie and would appreciate any feedback on my code. Perhaps there is a better/simpler way to do this in php and if so please fill me in, thanks. | ||
| 189 | Convert "hours:minutes" to "total_minutes" and back | mp96brbj |
| The first function here will convert hour:minute strings like "1:45" into the total number of minutes, in this case "105". The second function will do the opposite. | ||
| 198 | DateObj - date arithmetic class | yyogev |
| This class can be set by timestamp or year,month&day. Methods include: * set methods as described above * get methods for year, month, day of month * equals( <other DateObj> ) - checks if the the other nstance has the same date * getNextDay() - retuens a DateObj instance with the date of the following day * getNextMonth(), getNextYear() - returns a DateObj instance with the date a month after this one or a year after this one * diff( <other DateObj> [, <unit>] ) - returns the difference between the timestamps of this instance and the other, measured in the given unit. * toString( [<format>] ) - returns a string represting the date it has. uses the date() function to format this string. | ||
| 202 | PostgreSQL date converter | pap_man |
| This converts PostgresSQL date_timestamps to something PHP can work with. The time part was giing me trouble (it was way off) so I left it out. The function still has a place for it, I just left the formatting out. | ||
| 215 | Date Validator | morphy |
| a date validator :) warning Y10K bug | ||
| 1431 | PHP OOP Class for count down to any date or event | bonniek |
| Originally ctreated by sid trivedi on php manual. | ||
| 1336 | VCalendar - an open source web calendar | webinventor |
| VCalendar (Virtual Calendar) is an open source Web calendar application with related tools, for posting and maintaining events and schedules online, in calendar format. This is an excellent and free solution for use by online Web communities and any commercial and non-commercial organizations. Unlike any other online calendars, VCalendar comes with source code in multiple programming languages: PHP, ASP and ASP.NET (C# and VB.NET); with potential for adding more technologies in the future. | ||
| 240 | Day Chooser | mavetju |
| Easy to use interface to choose a day between two dates. | ||
| 241 | mysql Timestamp(14) to .beat | spacemax |
| simple code converts a mysql timestamp(14) to swatch .beat | ||
| 253 | date_to_timestamp function (and back) | hulstste |
| Two basic functions to convert a mySQL date to a UNIX timestamp and back. | ||
| 1204 | Compensate for server and user to return local time | theprawn |
| When developing scripts that display time, it can be tedious trying to manually compensate for the server (as well as desired zone) offset -- especially when DST is an issue. This function will automatically compensate for the server time GMT deviation and then convert to the target time zone. This can be especially useful in user-driven scripts, if you wish to allow users to specify their own GMT offset. The function can be used to convert any unix epoch time stamp, whether current time or an old forum post. It returns the time stamp, so you can format the date as you like externally. ( e.g. date("r",makeTime()); ) | ||
| 293 | Day of week functions | mmotley |
| Contains two functions, dayofweek() will return the day of the week for a given date (0=Sunday, 1=Monday, etc). nthDayOfMonth() will return the date of the nth weekday of a month (i.e. 2nd Tuesday of April 2001 will return 10). | ||
| 303 | get_elapsed_time() | befriend |
| Calculates elapsed time between two dates in MySQL DATETIME format, with formatting options (units, decimals)for output. | ||
| 340 | Leap year | maybl8r99 |
| Just a short practice run for me. A function that checks for leap year. | ||
| 350 | Finding Holidays | heymeadows |
| Here's a couple of functions that will allow you to define some holidays and their dates. You can also define dates for non-fixed holidays (eg. 3rd sunday of June). | ||
| 405 | Simple calender and scheduler | riaz_md |
| Simple calender and scheduler script. It displays calender for anymonth upto year 2010 and lets users add events to the dates. To view the script in action and to download the script, visit : http://rockhopper.monmouth.edu/~s0451223/calender/calender.php | ||
| 408 | MySQL Timestamp(14) to Human readable (HTML format) String | hachiihcah |
| A simple converter that does a helpful (and eye-strain preventing) conversion from a MySQL Timestamp(14) to a much easier to read format. Brought to you by www.hachisoft.com | ||
| 1242 | Active Calendar :: Create XHTML Calendars with PHP | georgiost |
| Active Calendar is a PHP class that generates calendars (month or year view) as HTML tables (XHTML-Valid). It can produce static calendars without any links or calendars with navigation controls, a date picker control, event days and content with event URLs, and linkable days (optionally URL or Javascript). The layout can be configured using CSS, and JavaScript is not required. The supported dates (on systems using a 32-bit signed integer Unix time_t) are: 1902-2037 (Unix) and 1971-2037 (Windows), when using the default PHP native date functions, and 100-3000 and later, when using the ADOdb Date Library. More details (latest packages with source code documentation, examples etc.) at: http://freshmeat.net/projects/activecalendar/ | ||
| 482 | MySQL Date Validation and Conversion | esammons |
| This function accepts a date field in various formats (like mm-dd-yyyy, yyyy/mm/dd, etc.), and validates that it is a correct date, then converts it to standard MySQL format (yyyy-mm-dd). | ||
| 492 | custom user format function | tony_bibbs |
| If you have a web application where you have many user accounts you can let the user customize the format of their date and time. In your user->preferences screen within your application add a drop down of possible date/time formats and store it in your users table. This function will read the format from that table and format it and return the formated time and unix timestamp in case you may need it. The date/time you pass this function can be in almost any format (english string, timestamp) and if you don't pass a date to this function it will return the current date/time in the user-specified format. You'll also see the code will read a default value from a config file just in case the user doesn't specify a format. | ||
| 534 | Date Calculating | gregoryb |
| This is my first posting to PHP Builder. I was in need of a date calculation snippet that would just add a the number: 30,60,90, or 120 to a date. With help from Sams publishing: "PHP and MySQL" this is what I came up with. | ||
| 539 | Nth Weekday Of Every Month | lampfire |
| Essentially a timestamp that returns the date of the next nth weekday of a month. (E.g. the 4th Tuesday or the 1st Monday of every month. Many events are scheduled by this formula.) Allows for wide range of output formats using the same codes as date(). Written with organizations that have monthly meetings in mind, particularly non-profits. You may modify it to suit your own needs, however. Great for keeping time sensitive pages up to date. | ||
| 555 | Very long date! | lonelywolf |
| this is a customizable function base on date() that return a string: Name of the day - date (number) - name of the month - year (4 digits). Just change name of the day and name of the month to your language! (I'm a beginner!) | ||
| 575 | Date class | xyzaecho |
| This first version of the Date class is for evaluation. It performs date arithmetic such as difference between two dates, adding days/hours/week/minutes/seconds, etc... This class needs enhancements for it cannot compute before 1970. | ||
| 688 | Date of Last Sunday | davent |
| This function returns the date of the last sunday from the current date in the form dd/mm/yyyy | ||
| 1243 | convert clarion date into a "real" date | phalseid |
| i have been working with some legacy dos and clarion stuff. couldn't find the answer and pieced it together here.... if you are a paychoice user you know all about this....or not.... | ||
| 633 | Working days function | cronky |
| Quick and dirty function to return the day, month and year adjusted for adding x amount of working days (i.e. it works out what is a working day and what isn't). It is quick and dirty can could probably use a re-write... | ||
| 658 | No: days Calculator | johngt |
| Calculate the no: of days between two given dates. | ||
| 660 | Subtracts two dates | yendor |
| returns the difference between two date as an integer | ||
| 683 | Calender Code Lite | tipera |
| The is the shortest code I could come up with for displaying a calender. It works on PHP Version 4.1.2. I don't know about anything else. | ||
| 699 | Sunset/Sunrise Calculator | snyder |
| This function gives you the time for sunrise or sunset for a particular day at a particular location. | ||
| 710 | Scrollable monthly calendar w/events from db | alinebernstein |
| A twist on the calendar w/links to db posted by inferno, this program displays one month at a time with a list of events (from the db) below the calendar. Prev and Next links let you scroll thru any number of months and years. | ||
| 719 | Dynamic Greeter Script | collegebuddy |
| A PHP script that retrieves date and time information and spits out a tailored greeting. The script outputs a greeting based on most common United States holidays and defaults to a generic "Good morning/afternoon/evening" on non-holidays. | ||
| 736 | Age,Weekday calculator. | nageshyd |
| The file takes a date of birth like dd-mm-yyyy or dd/mm/yyyy and calculates the number of years and days passed by and gives the weekday. The best part is it works for any year from after death of christ to till date. even the leap years are also considered | ||
| 738 | Pull Down Menus | louisp |
| Displays a pull down menu with the numbers available to select instead of a textbox with yyyy-mm-dd. | ||
| 743 | Unix timestamp to Readable date (and back) | locke |
| These 2 simple functions convert unix timestamp to readable date and back. Inludes full documentation of functions. | ||
| 779 | Workdays Elapsed for Current Month | nugod777 |
| This can basically be used as an include file. It calculates the number of workdays that have elapsed in the given month. Holidays are editable and excluded. | ||
| 849 | Check dates interval function | mdaniel2x |
| Check dates interval from two edit boxes inputed in form dd-mm-yyyy (instead of - sperator u can use . or /) | ||
| 850 | Simple days ahead function | mdaniel2x |
| Function that increment date with given days inputed. | ||
| 871 | time to text | teezee |
| This function returns, for a given number of seconds how long ago it happened. For example: echo "this message was posted ".timetext(1036148464)." ago"; would say something like ' this message was posted, one month, 2 days, 14 hours and 10 minutes ago' Have fun! | ||
| 879 | Bs_StopWatch | blueshoes |
| class to measure time intervals in microseconds. class to measure time intervals in microseconds. You can take times during a code run and at the end get a time table as HTML or text table. The output will contain total and as delta between each take in microseconds. for a howto go to: http://www.blueshoes.org/howto/Bs_StopWatch.pdf Free Code; This Class is part of the BlueShoes PHP Application Framework, see blueshoes.org. | ||
| 883 | PHP Date Chooser | kbrill |
| I was looking for the easiest, quickest way to add a date picker to my internal web site without having to add more javascript or a pop-up window. I found several fantastic javascripts to add calendars to the page and a few even used layers instead of pop-ups, but I was looking for something simpler. I noticed that although the javascript calendars will allow you to pick a date years away, most of my users were picking dates in the next 60 days and no more than 120 ever. So for my application I came up with this. Quick and easy you just call the function whereever you want the date dropdown to show up. You can force the name of the <select> field with the $default param and you can specify the number of days to display with the $size param. http://www.multi.com/Coding/PHPDateDropDown.php | ||
| 885 | Billing and Due Dates | defconone |
| Computes billing and due dates | ||
| 887 | Add "th", "nd", "st", "rd" suffixes to numbers | danielson2k |
| This function takes any number and adds the correct suffix to it, ie. 3 would return 3rd, 111 would return 111th | ||
| 888 | Advance date to the next X business days. | mnirwan |
| Takes a date, and advance it to the next X business days. If the date falls on weekend, then it'll advance from the next Monday. For example, you have 3 processing days for all orders: Given Order Date: 2002-12-31 Script will return Ship date: 2003-1-3 @param $orderDate the starting date in the form YYYY-MM-DD or YYYY/MM/DD | ||
| 897 | Time Date Convert | kakchan |
| This simply script is very usefull when your server is outside your timezone and you want to view the correct time/date, you can reach me at my site: http://www.dawnofdreams.org | ||
| 934 | Fiscal Calculator | eron123 |
| A function to generate the first and last date of a fiscal month given a month (1-12) and year. | ||
| 937 | Timediff | fraggalot |
| /* TIMEDIFFERENCE SCRIPT BY FRAGGALOT @ ATCC.NO, COPYRIGHT 2002 * GET HOW LONG AGO SINCE SOME TIMESTAMP * syntax; * timediff(timestamp[,how big[,special format]]) * timestamp: format of time() * how big: ex. 2: 3hours 4minutes. * another ex. 4: 1day 3hours 4minutes 34seconds * special format: if set to true the timestamp var comes in hh/minmin/ss/mm/dd/yyyy format. * */ | ||
| 942 | UK Date Formating | darkrahn |
| Keeps UK date formating dd/mm/yyyy displayed correctly, and does not output in US format of mm/dd/yyyy. Original idea of using array by swativ but his code still displayed in US format so i did not think that this snippet was classed as a revision. | ||
| 952 | UK Tax Week Calculator | waveydavey |
| Function returns UK tak week accoring to Inland Revenue rules. Not exciting, but useful. | ||
| 954 | FormatMySQLDateTime | trube |
| Takes date, time, datetime, timestamp and year MySQL values and converts them in to nice date/time formats. | ||
| 1259 | Time differnce functions for mins and hrs | kthakore |
| Two functions that return difference in hrs and mins. | ||
| 1219 | countdown script | jambo |
| displays time left until an event will occur using text and numbers; easy to use; can be adapted to your needs | ||
| 964 | LDAP timestamp converter | delder |
| Converts an LDAP timestamp of the form yyyymmddhhmmsst to a Unix timestamp. | ||
| 1165 | simple calendar | upaw04 |
| display current calendar date... | ||
| 985 | Get age | danielson2k |
| This function gets the age of a person from their date of birth in either the format DDMMYYYY or MMDDYYYY. To call the function use getage("25051983") for DDMMYYYY or getage("25051983", "mdy") for MMDDYYYY. | ||
| 1012 | Calculate difference in dates, using only workdays | mygov |
| This Function will take two dates, and calculate the difference between them in terms of working days, excluding holidays. I'm sure that someone could take this and clean it up a bit to make it run faster. I just needed something asap. Based on cronky's Working Days Function. I added modifications from heymeadows Finding Holidays function, and some other little stuff. | ||
| 1026 | Project Calendar | jimee |
| First attempt at a usable, upgradeable calendar module. | ||
| 1289 | phpCalendar Class | swdzchef |
| phpCalendar provides a class interface to the PHP calendar/date functions. It is intended to be helpdeul in allowing programmers provide calendar features in their applications. You can get the package at http://www.coastallighthouse.com/index.php?target=phpcalendar . | ||
| 1106 | Convert MySQL Date/Time into your own format. | mogul |
| This function allows you to pass in a MySQL Date/Time value and retrieve a Date/Time value according to the specified format. The following are example of the function call: echo formatSQLDateTime('2003-12-23 10:55:05', 0, 'd/m/Y - H:i:s'); echo formatSQLDateTime('2003-12-23', 1, 'jS F, Y'); echo formatSQLDateTime('10:55:05', 2, 'g:i a T'); Out put will be as shown below: 23/12/2003 - 10:55:05 Date Format is incorrect 10:55 am Singapore Standard Time Read the comments in the script for proper use of function. Comments/Suggestions are welcome. | ||
| 1310 | OpenBookings.org | jroger |
| Openbookings.org is an online booking software that allows to manage in an unified way the timetables of all the shared resources of your group, association or company (vehicles, conference rooms, computers, video projectors, cameras, ...). | ||
| 1128 | MyDate | gruff |
| Function which validates and converts into a Unix timestamp almost any form of text date without resorting to drop down boxes, etc on web pages. Accepts days and years in numbers, and months as numbers, abbreviations or full names in English, eg 21/January/04 or 21 jan 2004 - can use -, / or space as delimiter. When in doubt, will assume dd/mm/yy was input - that's the norm where I live. Please mail me if you have any comments or suggestions - this is a work in progress! | ||
| 1141 | Start and End of Week | srajpal |
| Start and End of Week | ||
| 1157 | World Time | depace |
| Returns current time of any place. Just pass the GMT hour and minute difference. | ||
| 1158 | date validation | upaw04 |
| a date validation that accepts YYYY-MM-DD,YYYY/MM/DD,MM-DD-YYYY and MM/DD/YYYY format | ||
| 1382 | Easy dates | jon001 |
| A short piece of code to help move dates and times around. Store the date and time in one column in mysql and use this to help display it however you want. My first post and first explode() function. A very proud moment. | ||
| 1424 | Elapsed Time | inuwashi |
| The elapsed:: class keeps a record of a specific time using a simple text file referred to as a Token. It provides simple tools to check elapsed time. | ||
| 1433 | Simple but very modifiable PHP countdown to specified date | znebula |
| This you guys can just copy and paste right into the body on a php page. It will display the days, hours, and minutes until the date and time you specify. If you want the is the variable for seconds made for you to use. It also has a nice little function that changes what is displayed depending on if the result is more than one or less than one. In this case it displays either "days" or "day" to let the company know the estimated time for updating the server. So use for whatever you want. I know I've snipped plenty of code myself!! Always a very useful tool when learning a new language. This also my first time ever submitting anything so any tips or comments you've got are appreciated. | ||
| 1438 | Recurring Date Checker | cullenlinn |
| This function lets you check whether an date event should recur on a specified date. This is handy for calendar, billing and reminder applications. | ||
| 1441 | date / date-time select list generator | caleblloyd |
| generates an HTML select list that defaults to the current date or date/time, or sets the date or date/time to user specified values. $name is the select list base name. each select list will have either y (year) m (month) d (day) h (hour) or i (minute) immediately following the base name. variables $y, $m, $d, $h, $i, can be passed into the function in order for it to default to a certain date or date/time. | ||
| 1448 | the next html | aandfix |
| its me all | ||

