13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Next<br />

481<br />

To give you a taste for these functions, consider the prototypes for the functions you<br />

would use to convert from the Gregorian calendar to the Julian calendar:<br />

int gregoriantojd (int month, int day, int year)<br />

string jdtojulian(int juli<strong>and</strong>ay)<br />

To convert a date, you would need to call both of these functions:<br />

$jd = gregoriantojd (9, 18, 1582);<br />

echo jdtojulian($jd);<br />

This call echoes the Julian date in a MM/DD/YYYY format.<br />

Variations of these functions exist for converting between the Gregorian, Julian,<br />

French, <strong>and</strong> Jewish calendars <strong>and</strong> Unix timestamps.<br />

Further Reading<br />

If you would like to read more about date <strong>and</strong> time functions in <strong>PHP</strong> <strong>and</strong> <strong>MySQL</strong>, you<br />

can consult the relevant sections of the manuals at http://php.net/manual/en/ref.<br />

datetime.php <strong>and</strong> http://dev.mysql.com/doc/refman/5.0/en/date-<strong>and</strong>-timefunctions.html.<br />

If you are converting between calendars, try the manual page for <strong>PHP</strong>’s calendar<br />

functions: http://php.net/manual/en/ref.calendar.php.<br />

Next<br />

One of the unique <strong>and</strong> useful things you can do with <strong>PHP</strong> is create images on the fly.<br />

Chapter 22,“Generating Images,” discusses how to use the image library functions to<br />

achieve some interesting <strong>and</strong> useful effects.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!