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
  1. #1
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts

    php current day date

    hi ,


    i want to know how can i use the php function to know that current date
    Initially i was using unix time stamp.

    what i want is

    Code:
    if (now date is 26 feb)
           do this 
    
    if(now date is 27 feb)
       do thta

    with unix time stamp method i had to use

    Code:
    $from = strtotime("26 Feb 2008");
    $to 	= strtotime("27 Feb 2008");
    
    if(now >from and now <to)
    do this

    so here i had to use two variables from and to to get date of 1 day 26 feb

    Is there any function which can do it in one step e,g

    Code:
    if (now = 26 feb)
    .....
    
    starting from 1 st second of 26 feb to last second of that day
    Please de-reputate me
    © 0o0o0o0

    Its better to rule in Hell then to serve in Heaven

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    PHP Code:
    $today date('j M');

    switch(
    $today)
    {
        case 
    '25 Feb':
            echo 
    'today is the 25th of February';
        break;

        case 
    '26 Feb':
            echo 
    'today is the 26th of February';
        break;

        case 
    '27 Feb':
            echo 
    'today is the 27th of February';
        break;


  • #3
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts
    thanks dude
    i want to compare the next seven days in advance how can i do that e,g

    Code:
    $next = $today + $i
    where $i is variable for next 7 days

    then i have to copmare its 26 or 27 or 28 feb
    Last edited by o0O0o.o0O0o; 02-26-2008 at 05:25 AM.
    Please de-reputate me
    © 0o0o0o0

    Its better to rule in Hell then to serve in Heaven

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Not sure what you're asking, but to get the date of the next day you would use something like this:
    PHP Code:
    $next date('j M'strtotime('+1 day')); 

  • #5
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts
    can i use

    PHP Code:
    $next date('j M'strtotime('+".$i." day')); 
    Please de-reputate me
    © 0o0o0o0

    Its better to rule in Hell then to serve in Heaven

  • #6
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Quote Originally Posted by o0O0o.o0O0o View Post
    can i use

    PHP Code:
    $next date('j M'strtotime('+".$i." day')); 
    No but you can use:

    PHP Code:
    $next date('j M'strtotime("+".$i." day")); 

  • #7
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by Andrew Johnson View Post
    No but you can use:

    PHP Code:
    $next date('j M'strtotime("+".$i." day")); 
    Or:
    PHP Code:
    $next date('j M'strtotime('+' $i ' day'));
    // or
    $next date('j M'strtotime("+$i day")); 
    Edit: I guess I should point out that this would be a little slower(roughly 0.0004 seconds) than just adding 86400(the number of seconds in a day) to time(); or multiplying the number of days by 86400, and then adding it.
    Last edited by Inigoesdr; 02-26-2008 at 11:11 PM.


  •  

    Posting Permissions

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