Bickey Posted January 26, 2011 Share Posted January 26, 2011 How do I echo the time in SECONDS? $tz = new DateTimeZone('America/Chicago'); $date = new DateTime('now', $tz); $mtime = $date->format('Y-m-d H:i:s'); echo ($mtime); E.g. 1296057739 Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/ Share on other sites More sharing options...
DJTim666 Posted January 26, 2011 Share Posted January 26, 2011 Calling the date() function without parameters will give you a timestamp. This would be the same for the time() function aswell Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/#findComment-1165491 Share on other sites More sharing options...
Bickey Posted January 26, 2011 Author Share Posted January 26, 2011 Thanks. But I'm having problems when I echo a time in different time zone. I get complaints from other countries saying they see different a time than the time. How can I solve this and make php echo a time for a particular time zone? (America/Chicago) Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/#findComment-1165503 Share on other sites More sharing options...
MatthewJ Posted January 26, 2011 Share Posted January 26, 2011 you're wanting to get the timezone from the client pc. In that case, you would need to use something like javascript. Obviously that would rely on users having javascript enabled.. not much of an issue these days. Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/#findComment-1165526 Share on other sites More sharing options...
Bickey Posted January 26, 2011 Author Share Posted January 26, 2011 Isn't there a way to echo a time for a particular time zone? Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/#findComment-1165544 Share on other sites More sharing options...
smerny Posted January 26, 2011 Share Posted January 26, 2011 http://php.net/manual/en/function.date-default-timezone-set.php Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/#findComment-1165545 Share on other sites More sharing options...
MatthewJ Posted January 27, 2011 Share Posted January 27, 2011 Oh, what he said Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/#findComment-1165883 Share on other sites More sharing options...
ignace Posted January 27, 2011 Share Posted January 27, 2011 Calling the date() function without parameters will give you a timestamp. This would be the same for the time() function aswell Calling date without parameter returns a nice warning: "date() expects at least 1 parameter" Quote Link to comment https://forums.phpfreaks.com/topic/225740-in-seconds/#findComment-1166116 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.