Different ways of date display,I have included in following table you can change order of letters and make different ways of display in your own.
m/d/y | 06/16/12 |
m/d/Y | 06/16/2012 |
n/j/Y | 6/16/2012 |
M/j/Y | Jun/16/2012 |
F/j/Y | June/16/2012 |
M/D/Y | Jun/Sat/2012 |
Y / M / D | 2012 / Jun / Sat |
y - M - D | 12 - Jun - Sat |
y - M - d | 12 - Jun - 16 |
Y - M - d | 2012 - Jun - 16 |
Y - F - d | 2012 -June- 16 |
d -F- Y | 16 -June- 2012 |
d -M- Y | 16 -Jun- 2012 |
d -m- Y | 16 -06- 2012 |
d -m- Y | 16 -06- 12 |
d -n- Y | 16 -6- 12 |
j -n- Y | 16 -6- 12 |
For creating above table following codes are needed.
<?php echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>m/d/y</td><td>".date("m/d/y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>m/d/Y</td><td>".date("m/d/Y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>n/j/Y</td><td>".date("n/j/Y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>M/j/Y</td><td>".date("M/j/Y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>F/j/Y</td><td>".date("F/j/Y")."</td></tr>"; echo "<tr bgcolor=#ffffff><td>M/D/Y</td><td>".date("M/D/Y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>Y / M / D</td><td>".date("Y / M / D")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>y - M - D</td><td>".date("y - M - D")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>y - M - d</td><td>".date("y - M - d")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>Y - M - d</td><td>".date("Y - M - d")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>Y - F - d</td><td>".date("Y -F- d")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>d -F- Y</td><td>".date("d -F- Y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>d -M- Y</td><td>".date("d -M- Y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>d -m- Y</td><td>".date("d -m- Y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>d -m- Y</td><td>".date("d -m- y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>d -n- Y</td><td>".date("d -n- y")."</td></tr>"; echo "<table bgcolor=#ff9900><tr bgcolor=#ffffff><td>j -n- Y</td><td>".date("j -n- y")."</td></tr>"; echo "</table>"; ?> |
Find Leap Years
leap day is a date that occurs in most years that are evenly divisible by 4.In Leap year month of February ends with 29 days.By creating the following php file you could find the year you have entered is a leap year or not.
File HTML Layout and codes are bellow.
| <?php $year=$_POST['year']; function last_day_of_feb ($year) { $ultimo_feb_str = $year . "-03-00"; $ultimo_feb_date = date_create($ultimo_feb_str); $return = date_format($ultimo_feb_date, "Y-m-d"); return $return; } ?> <form name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table bgcolor=#d38a2a align="center"><tr bgcolor=#ffffff><td>Year</td><td><input type="text" name="year"></td></tr> <tr bgcolor=#ffffff><td>Click Find</td><td align="right"><input type="submit" value="Find"></td></tr> <tr bgcolor=#ffffff><td>Febuary end date</td><td align="right"><?php echo last_day_of_feb($year); ?></td></tr> </table> </form> |
Adding Number of days to a given date
Calculations with the dates are different with other numerical calculations because month have 1-28/31days while year having 12 months.Following example shows you how to add number of days in to a date(today).
<?php echo date('Y-m-d', strtotime("+164 days")); ?> |
out put is 2012-11-27 |
|
Powered by Moon Calendar
|
No comments:
Post a Comment