SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot ozonew4m's Avatar
    Join Date
    Apr 2006
    Location
    at my desk
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stuck in a time warp - please help

    ok.. i know you guys must be sick of date questions huh?

    this is for a 30 day trial period,

    ok ive got 2 variables:

    Code:
    $trialstarted = "2006-12-01 00:00:00";
    $now = "2006-12-01 00:00:00";
    how do i get

    Code:
    $trialexpireson = "?";
    $timeleftuntiltrialexpires = "?";
    please help me or ill be stuck in this timewarp for ages

  2. #2
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?PHP

    $startDate 
    '12/1/2006 00:00:00'//The trial period started on 1 december 2006
    $startTimestamp strtotime($startDate);

    //trial would last for 30 days so
    $endTimestamp = ($startTimestamp 30 24 3600);

    //what is current timestamp
    $current time();

    $difference $endTimestamp $current;
    echo 
    'Your trial period ends in ';
    echo 
    floor($difference 84600);
    $difference -= 84600 floor($difference 84600);
    echo 
    ' days, ';
    echo 
    floor($difference 3600);
    $difference -= 3600 floor($difference 3600);
    echo 
    ' hours, ';
    echo 
    floor($difference 60);
    $difference -= 60 floor($difference 60);
    echo 
    " minutes, and $difference seconds later.";
    echo 
    "<br />";
    echo 
    "On " date'd F Y H:i:s'$endTimestamp);
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •