<?php /** * example.php * * @author Miguel Villaseñor Garduño * * Examples of use of the mkBirthday Class * */ require "mkBirthday.php"; if(isset($_POST['action'])){ $birthday = new mkBirthday($_POST['date']); switch($_POST['action']){ case 'until': $result = $birthday->getDaysUntilNext()->format('%m months y %d days until next birthday'); break; case 'age': $result = $birthday->getAge()." years"; break; case 'is': $result = $birthday->isBirthday()?'true':'false'; break; } } ?> <html lang="es"> <head> <meta charset="utf-8"> <title>MkBirthday Examples</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript"> $(function() { $( "#date" ).datepicker({ dateFormat:'yy-mm-dd', changeMonth: true, changeYear: true }); }); </script> </head> <body> <h1>MkBirthday Class Examples</h1> <form method="post"> <fieldset> <legend>Example</legend> <input type="text" name="date" id="date" /> <select name="action"> <option value="until">Get days until next birthday</option> <option value="age">Get age</option> <option value="is">Is Birthday</option> </select> <input type="submit" /> <br/> <?php if(isset($_POST['action'])){ echo $result; } ?> </fieldset> </form> </body> </html>
|