Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Date Woes

  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts

    Date Woes

    Hi guys,

    Trying to parse a date from a known dat to compare with current date:

    PHP Code:
    $next_birthday '2007-08-08';
    mktime(date('g'),date('i'),date('s'),date('m',time($next_birthday)),date('j',time($next_birthday)),date('Y',time($next_birthday))); 
    The if else script is returning the current mktime and not the date's mktime.

    Any help appreciated.

    D.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #2
    Regular Coder
    Join Date
    Mar 2005
    Location
    D0u$h!t3 k4?
    Posts
    512
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Ever thought about strtotime or are you wanting to convert the date to an integer yourself? Also, you might try date_parse. It takes a string containing a date and returns an array with the year, month, day, hour, minute, second, fraction of a second, warning count, warnings (a nested array), error count and errors (a nested array) as well as an is_localtime boolean value. On failure to parse properly, the function returns FALSE.

    I recommend trying it out.
    Last edited by rpgfan3233; 11-15-2007 at 02:00 PM.
    PHP Code:
    $hello file_get_contents('hello.txt'); echo $hello
    hello

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    PHP Code:
    $next_birthday '2007-08-08';
    if(
    date('Y-m-d') == $next_birthday)
    {
        
    // happy birthday
    }
    else
    {
        
    // back to work


  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Quote Originally Posted by Inigoesdr View Post
    PHP Code:
    $next_birthday '2007-08-08';
    if(
    date('Y-m-d') == $next_birthday)
    {
        
    // happy birthday
    }
    else
    {
        
    // back to work

    You don't have to work on your birthday? You are lucky...

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by aedrin View Post
    You don't have to work on your birthday? You are lucky...
    I usually take a sick day.

  • #6
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Thanks guys I knew I had done it before but could not remember how and then it came to me strotime rather than time

    Thanks guys.

    PS: I take sickies on my birthday too, usually!

    D.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #7
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    I've been missing out! Well, I guess that's what I'll have to do on my birthday.


  •  

    Posting Permissions

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