Code Snippet: Date converter
Snippet: Date converter
Description:
This tiny piece of code takes care that you can display a standard date instead of the mysql date (2005-02-23)
Example:
echo date(”d m Y”, “2005-02-23″);
Shows:
23 02 2005
Code:
PHP:
Snippet: Are sessions working?
Description:
You can use this piece of code to check if it is possible to use sessions for the visitor.
This can come handy for login pages. If you have cookies disabled and try to login, no login session can be used. In such cases it is nice to inform […]
Code Snippets: Calculate Age
Snippet: Calculate age
Description:
With this function you can calculate the age of a person
Example:
echo “Age is: ” . birthday (”1984-07-05″);
Result will be (23 Feb 2005) = “Age is: 20″
Code:
PHP:
<?php
//calculate years of age (input string: YYYY-MM-DD)
function birthday ($birthday){
list($year,$month,$day) = explode(“-”,$birthday);
$year_diff = date(“Y”) - $year;
$month_diff = date(“m”) - $month;
$day_diff = date(“d”) - $day;
if […]

