daydreamer Posted September 23, 2008 Share Posted September 23, 2008 I am using the getdate() function for the time in one of myscripts. It keeps giving me different hours! one hour itll be 23.22, one hour later its 23.22. The minutes will be accurate, just the hours will always be off and seem to be right sometimes, and another time itll be an hour out. I have changed the line in my php.ini file to this: date.timezone =GB Anyone know why my time isnt always accurate? Thanks. Link to comment https://forums.phpfreaks.com/topic/125544-getdate-something-is-wrong/ Share on other sites More sharing options...
kenrbnsn Posted September 23, 2008 Share Posted September 23, 2008 Can you post the code where you're using the function? Ken Link to comment https://forums.phpfreaks.com/topic/125544-getdate-something-is-wrong/#findComment-649115 Share on other sites More sharing options...
Maq Posted September 23, 2008 Share Posted September 23, 2008 Why not use date() and format it as you need it: $today = date("H:i:s"); // 17:16:17 Check out: http://us2.php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/125544-getdate-something-is-wrong/#findComment-649119 Share on other sites More sharing options...
daydreamer Posted September 23, 2008 Author Share Posted September 23, 2008 <?php $now = getdate(); print_r($saved); echo "<br>"; print_r($now); echo "<br>"; echo "saved hour:".$saved["hour"]."<br>"; echo "saved minute:".$saved["minute"]."<br>"; echo "now hour:".$now["hours"]."<br>"; echo "now minute:".$now["minutes"]."<br>"; ?> $saved comes from a mysql record. I just tried $today = date("H:i:s"); but its exactly the same time. I am using getdate() because it automatically puts it into an array for easy processing, which i need to do for calculations, because i need to run a certain function after 10mins has passed from the last saved date in the mysql db. Link to comment https://forums.phpfreaks.com/topic/125544-getdate-something-is-wrong/#findComment-649127 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.