SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    retrieve current date

    PHP Code:
    $current_date     date('Y-m-d');
    $current_time    date('G:i:s');
    $current_time    date('G:i:s'strtotime("+8 hours"strtotime($current_time))); 
    now i can retrieve the current time. but how to retrieve the current date...?
    thanks in advance...

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $current_date     date('Y-m-d',time()); 
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SilverBulletUK View Post
    PHP Code:
    $current_date     date('Y-m-d',time()); 
    when i echo the date, is not correct yet...
    for example, now in my country, the date is 2009-01-10.
    but when i echo the first line, the date is 2009-01-09.
    so how to make it when the time + 8 hours, the date will be auto adjusted to 2009-01-10...?

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it is works... thanks for helping....
    this method is easier to echo the date and time... i even don't need to add 8 hours for the time.....


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
  •