How can I create a calendar in PHP?
Today should be in bold. How could it be coded?
You can try dhtml Calendar, or maybe Yahoo UI's Calendar.
PHP: date should give you everything you need.
Then, format everything in a table.
Firstly, start by capturing your requirements (should it handle month browsing, should it show a week at a time, etc.) - this should let you derive a functional spec of sorts, which should guide you when actually writing the component/page/application
If you mean: "how to show a date picker on your web page from PHP", the answer is to use some default JavaScript library for it. E.g. Dojo or jQuery.
Related
I am trying to add a Google calendar to a website I'm making that the client will be able to update themselves. I found this: http://mikeclaffey.com/google-calendar-into-html/ which has been quite helpful, but I am a bit stuck.
The website I am building is using PHP template and the page contents is contained within the $content variable. Here is the link I'm working on: http://victoriasawyer.com/AmosTheTransparent.
The calendar feed is the top one of the two lists of Tour Dates. I would like the top one to look similar to the bottom one. The same would be ideal but not necessary.
The biggest issue I'm having is with the start date and time. In the title of the event I would like just the date to show (preferably like 10/03/14) not the time. I have figured out how to display just the time separately without issue. Is there some way to change the date format?
The other issue I'm having is the order that the events are appearing. I would like the events to show with the soonest one first in the list and the furthest one last in the list. I added the additional parameters as instructed in the tutorial (orderby=starttime and sortorder=ascending) but they do not display correctly.
The url I am using is: https://www.google.com/calendar/feeds/qmfadhgtq2kmabsi3dlb456v98%40group.calendar.google.com/public/full?orderby=starttime&sortorder=ascending&futureevents=true&alt=json. Is there something I can adjust or add to fix the order?
Any help will be much appreciated (even if you can recommend an alternative. It just needs to be customizable, and so far this seems to be the best option I have found).
You can use PHP's DateTime class like this:
$date = new DateTime('Sun Nov 16 2014 00:30:00 GMT+0000');
echo $date->format('Y-m-d');
You can then use the predefined formats in PHP which are listed here to format it into whatever style you like.
echo $date->format('d/m');
echo $date->format('d/m/Y');
I would like to display vacation and time offs on a linear calendar where the days of the months are the column names and rows are the employee names.
I know there is a way to achieve this using php and javascript but I would like to know if there is a shortcut solution that I can use to implement this quicker.
Use javascript to output a <table>, using something like SortTable or a javascript framework to output it.
Hook up some javascript on the table's click events, and use AJAX to ask PHP for the relevant information. The PHP script can call the database and output the information in something such as JSON.
Without any more specifics in your question I don't think you're going to get much more help.
I am working on form and I am looking for a free calendar/date/timestamp app that i can include in my form. basically, in the input text, i want users to click on the calendar icon and pick a date and a time stamp. that value should populate in the input text.
my next question is, in my mysql db, i am calling this field as "datetime", so i am hoping the values can be written in the db.
i am working with php and mysql.
thanks.
For the user interface you are describing to be added to the input field, jQuery Datepicker springs to mind.
http://jqueryui.com/demos/datepicker/
You'll need to include the jQuery library as well as the jQuery UI library. You can use the 'build your download' link and documentation on the jQuery library page to get a fully themed ui download to suit your design needs.
You'll need to make your form post to a server-side script that will take the field and insert it into the DB. Be careful - mysql date time is in the following format - YYYY-MM-DD HH:mm:SS. You can use strtotime and date to format the input from jQuery. After sanitizing the input, you could do something simple like:
date('Y/m/d H:i:s', strtotime($_POST['date']) )
You can use this to make sure in your server script that the date/time is in the proper format before it goes in the database.
This can be done with GUI
Take a look at jQuery UI Date-picker: http://jqueryui.com/demos/datepicker/
Regards to the date conversion there is plenty of functions to help you
http://www.php.net/manual/en/ref.datetime.php
How can I make a calendar in php so that the users will not have to input the date manually.
It's more a javascript feature, actually.
There are many javascript library to do this. One of it is jQuery UI DatePicker. I highly recommended this one.
I've been using the js calendar from http://www.dynarch.com/ and it's nice and it has many options like limiting the date selection within a period, multiple date selection etc.,
I want to show when the comment last posted in PHP. like 5 minutes ago, 2 days ago, 7 weeks ago. How to do this?
You can find plenty of answers with full solutions in different languages, pseudocode, ideas, etc.. here.
I believe there's an example of PHP too.
You can use timeago, a jQuery plugin, to do it via Javascript. It would yield the same result, update without refreshing, and by doing it client side instead of server side, you are not precluded from caching.
http://timeago.yarp.com/
Otherwise, Annurag has a link with some good PHP solutions.
You can do manual calculation in server, to get the time difference, then translate it into human time format.
Or my preference, do it in browser using javascript. Using this approach, the time in page can be updated without refresing the page.
You can use this jQuery EasyDate library to translate a DOM element into humane time format.
You can also read the comments in this post about Pretty Date by John Resig. It contain the code, and improvement by other.
Store the comment posted in the date DB and show the the same in the front end by comparing with current date and time using php function