chxxangie Posted January 9, 2009 Share Posted January 9, 2009 $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... Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/ Share on other sites More sharing options...
premiso Posted January 9, 2009 Share Posted January 9, 2009 That code does not return the current date? The first line of your code is the current date....so how is that not returning the current date? Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/#findComment-733462 Share on other sites More sharing options...
chxxangie Posted January 9, 2009 Author Share Posted January 9, 2009 ok... like 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...? Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/#findComment-733475 Share on other sites More sharing options...
abdfahim Posted January 9, 2009 Share Posted January 9, 2009 I think you are looking for putenv("TZ=YOUR_TIME_ZONE"); www.php.net/putenv Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/#findComment-733481 Share on other sites More sharing options...
chxxangie Posted January 9, 2009 Author Share Posted January 9, 2009 I think you are looking for putenv("TZ=YOUR_TIME_ZONE"); www.php.net/putenv may i know how to use this? i check some information of this, but i don so understand this function... Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/#findComment-733485 Share on other sites More sharing options...
abdfahim Posted January 9, 2009 Share Posted January 9, 2009 just use this line before you echo current date. putenv("TZ=Europe/Amsterdam"); // To return time+date of Amsterdam $current_date = date('Y-m-d'); echo $current_date; Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/#findComment-733490 Share on other sites More sharing options...
chxxangie Posted January 9, 2009 Author Share Posted January 9, 2009 just use this line before you echo current date. putenv("TZ=Europe/Amsterdam"); // To return time+date of Amsterdam $current_date = date('Y-m-d'); echo $current_date; this is a new knowledge for me... it can display the date and time as well... and i don't need to do extra calculation to add 8 hours for the time. thanks for your helping... thank you so much!!! Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/#findComment-733494 Share on other sites More sharing options...
abdfahim Posted January 9, 2009 Share Posted January 9, 2009 You are welcome .... here is the link for all the available TIMEZONES http://www.php.net/timezones Quote Link to comment https://forums.phpfreaks.com/topic/140168-retrieve-current-date/#findComment-733497 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.