All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

How to Calculate Days B/W to given Dates

  • # June 18, 2012 at 12:43 pm

    I Want to Know that how can i calculate the no. of days b/w the two given dates using php

    # June 18, 2012 at 3:36 pm

    This reply has been reported for inappropriate content.

    if you have the dates, convert them to unix timestamp, subtract the earliest date from the latest and then convert it back to number of days.

    $early = mktime(hour,minute,second,month,day,year,daylight savings?); //all of these are optional but should be set to 0 if not used.
    $late = mktime(hour,minute,second,month,day,year,daylight savings?);

    $days = ($late-$early)/86400; //number of seconds in a day

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed