Short Tag – Web Development Blog

Entries Tagged ‘php date’

Get month, day, year from timestamp functions [PHP]

Today I thought I can share you a few of my functions. Today’s article is an easy one, but I use the functions in almost all my websites, so I thought they can be useful to you.
So here are a few functions that get the year,month,day,hour,minute,second from a time stamp, similar to the MYSQL functions. [...]

Datediff function in PHP (similar to VB)

A function that calculates the difference between 2 dates.  It is very similar to the datediff function available in Visual Basic.

function datediff($interval, $datefrom, $dateto, $using_timestamps = false) {

if (!$using_timestamps) {

$datefrom = strtotime($datefrom, 0);

$dateto = strtotime($dateto, 0);


$difference = $dateto – $datefrom; // Difference in seconds

switch($interval) {

case ‘yyyy’: // Number of full years

$years_difference = floor($difference / 31536000);

if [...]