SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    858
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question about date comparisons

    When I run the following code, I get a UNIX timestamp for debugFeaturesLaunch, but not debugFeaturesLogin. Can someone see what I am obviously overlooking?

    Thanks!


    PHP Code:
    // $_SESSION[lastLogin] uses dates in the format of 01-30-2012

    $lastLogin strtotime($_SESSION[lastLogin]);
    $_SESSION[debugFeaturesLogin] = $lastLogin;

    $launchDate  "07-01-2012";
    $launchDate strtotime($launchDate);
    $_SESSION[debugFeaturesLaunch] = $launchDate;

    if (
    $lastLogin $launchDate) {
        
    $campaign "Features";
        
    $_SESSION[viewedCampaignToday] = "Yes";

    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    247
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    what does
    PHP Code:
    var_dump($_SESSION[lastLogin]); 
    say?

    make some others var_dump lines to check your values.

  3. #3
    SitePoint Enthusiast rajeev13's Avatar
    Join Date
    Nov 2012
    Location
    New Delhi,India
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by busboy View Post
    When I run the following code, I get a UNIX timestamp for debugFeaturesLaunch, but not debugFeaturesLogin. Can someone see what I am obviously overlooking?

    Thanks!


    PHP Code:
    // $_SESSION[lastLogin] uses dates in the format of 01-30-2012

    $lastLogin strtotime($_SESSION[lastLogin]);
    $_SESSION[debugFeaturesLogin] = $lastLogin;

    $launchDate  "07-01-2012";
    $launchDate strtotime($launchDate);
    $_SESSION[debugFeaturesLaunch] = $launchDate;

    if (
    $lastLogin $launchDate) {
        
    $campaign "Features";
        
    $_SESSION[viewedCampaignToday] = "Yes";

    according to me, the strtotime() accept the English date format as in its manual, i look around the web for English date format most of them exclude the mm-dd-yyyy format.otherwise this function works well most of the time.

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    What rajeev is saying is actually probably your problem:
    PHP Code:
    // $_SESSION[lastLogin] uses dates in the format of 01-30-2012 
    xx-yy-zzzz is interpreted as dd-mm-yyyy ; there is no Month 30.

    Reformat your string as xx/yy/zzzz to invoke the American interpretation of mm/dd/yyyy
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


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
  •