RON_ron Posted November 24, 2010 Share Posted November 24, 2010 I need to get the +10 timezone. But 1. The output for +10 is incorrect. Please help to fix it. 2. Is this a good way to get it? <?php echo "time=" (.time() + 36000); ?> Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/ Share on other sites More sharing options...
requinix Posted November 24, 2010 Share Posted November 24, 2010 date_default_timezone_set + date Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1138881 Share on other sites More sharing options...
RON_ron Posted November 24, 2010 Author Share Posted November 24, 2010 Can someone help me please... Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139026 Share on other sites More sharing options...
ManiacDan Posted November 24, 2010 Share Posted November 24, 2010 Do you mean aside from the help you've already gotten? Your code has a syntax error in it, in addition to being logically incorrect. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139037 Share on other sites More sharing options...
jim_keller Posted November 24, 2010 Share Posted November 24, 2010 Do you mean aside from the help you've already gotten? Your code has a syntax error in it, in addition to being logically incorrect. -Dan oh, do you mean the dungeon master style riddles he's gotten so far? This is a PHP help forum with a lot of beginners in it. If all you want to do is send people to the user manual or point out that the code HAS errors (without offering a fix), why even bother replying? Ron: Try something like the following code, but change the timezone ("Pacific/Nauru") to the one you need. They are listed here: http://www.php.net/manual/en/timezones.php $tz = new DateTimeZone('Pacific/Nauru'); $date = new DateTime('now', $tz); echo $date->format('Y-m-d H:i:sP') . "\n"; Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139043 Share on other sites More sharing options...
RON_ron Posted November 24, 2010 Author Share Posted November 24, 2010 jim_keller . You are dead correct... how can I get the time() in seconds? E.g. Same as how it echo here; <?php echo "time=" .time(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139047 Share on other sites More sharing options...
ManiacDan Posted November 24, 2010 Share Posted November 24, 2010 I didn't realizing linking him to the manual page describing the exact functionality he needs (along with pages upon pages of examples) was a "dungeon master style riddle." Next time someone asks me how to put a nail into a board, I'll give a dissertation on the use of a hammer. Click the links to the manual pages, read the manual pages, learn something. The last step is important. As for pointing out the syntax error, he received help and responded to it by simply asking for help. I gave him additional, nonspecific help to respond to his additional nonspecific request for help. The DateTime class and its related functions are PHP 5.2+ only, and a lot of the timezone functionality is 5.3+. Since all we had were 3 malformed lines of PHP, assuming he was on PHP 5.3 was too big of a jump for Requinix and me. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139054 Share on other sites More sharing options...
jim_keller Posted November 24, 2010 Share Posted November 24, 2010 I didn't realizing linking him to the manual page describing the exact functionality he needs (along with pages upon pages of examples) was a "dungeon master style riddle." Next time someone asks me how to put a nail into a board, I'll give a dissertation on the use of a hammer. Click the links to the manual pages, read the manual pages, learn something. The last step is important. As for pointing out the syntax error, he received help and responded to it by simply asking for help. I gave him additional, nonspecific help to respond to his additional nonspecific request for help. The DateTime class and its related functions are PHP 5.2+ only, and a lot of the timezone functionality is 5.3+. Since all we had were 3 malformed lines of PHP, assuming he was on PHP 5.3 was too big of a jump for Requinix and me. -Dan Then why don't you *say* that? I understand that some questions are total facepalms because it's like "where do I even begin?" but no one's forcing you to post responses. Additionally, some people aren't adept at paging through manuals describing pages of functionality about concepts they barely understand in the first place. It's nothing but developer pretension. Why not just post "RTFM" ? Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139060 Share on other sites More sharing options...
RON_ron Posted November 24, 2010 Author Share Posted November 24, 2010 Hey Dan... those 3 lines is my full php file. I'm using this only to retrieve the time() in my timezone(+10) and as SECONDS. This is for a countdown clock. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139064 Share on other sites More sharing options...
ManiacDan Posted November 24, 2010 Share Posted November 24, 2010 @jim: Why should we have to explain the reason behind linking someone to the manual? Don't you think linking someone to the manual implies "You should read this page, I am not linking to it because I'm practicing my linking skills"? @RON: You have been given the solution, twice now. Debug this on your own, or be more clear as to what "not working" means. Is the time on the server right? Do you know what timezone you're in? Have you tried the other two solutions you've been presented with? Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139080 Share on other sites More sharing options...
jeff5656 Posted November 24, 2010 Share Posted November 24, 2010 jim_keller: you are so correct! I hate when people give replies like "go read the manual". They could have offered a solution in the time it took them to reply. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139115 Share on other sites More sharing options...
KevinM1 Posted November 24, 2010 Share Posted November 24, 2010 Looking through the manual should be one of the first steps one should take to address a problem they have with the language. Reading through documentation is something all developers should be comfortable with. PHP's documentation is some of the best. It's clear, easy to read, and uses very little jargon. I don't think it's unreasonable for someone to be directed there as an answer. Also, while this is a place for people to get help, one shouldn't expect to be spoon fed the answers they are looking for. I found requinix's answer to be more than sufficient. He provided both functions the OP should use. Further, the manual pages do an exquisite job describing what the functions do, with relevant examples. Short of writing the OP's code for him, it was as good an answer as could be expected. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139140 Share on other sites More sharing options...
johnsmith153 Posted November 24, 2010 Share Posted November 24, 2010 I'm with jim_keller. This post is nothing though, there are many occasions out there that I see people provide a little attitude with their posts. Look at Nightslyr's recent posts. More 'pointing out where somebody is wrong' rather then helping to solve a problem. But when it's free, you can't really expect any more. I'd personally still rather people not reply though. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139166 Share on other sites More sharing options...
KevinM1 Posted November 24, 2010 Share Posted November 24, 2010 I'm with jim_keller. This post is nothing though, there are many occasions out there that I see people provide a little attitude with their posts. Look at Nightslyr's recent posts. More 'pointing out where somebody is wrong' rather then helping to solve a problem. But when it's free, you can't really expect any more. I'd personally still rather people not reply though. I don't see why pointing out where somebody is wrong can't be part of the learning experience. I'd much rather receive blunt criticism of my code and design than be strung along by someone who doesn't want to hurt my feelings. In fact, I have received that kind of treatment here in the past. It made me a better programmer. Telling me my code sucks fires up my desire for competition, which spurs me to learn and improve. For me, I personally grow frustrated when I see the following things: 1. Someone wanting to be fed the answer. 2. Someone who panics because their code doesn't run correctly the first time. 3. Someone who hasn't attempted to do any troubleshooting on their own. All three tend to indicate a lack of patience or work ethic. I react far more favorably to those that have demonstrably put forth an honest effort in solving their problems. It's not 100% accurate, but it's served me well in the vast majority of cases I've encountered. Finally, RTFM is a perfectly reasonable answer in many cases. In fact, we have a smile for it: Like I said before, it should be among the first steps someone takes before coming here.* *Yes, yes, there are exceptions. I try to treat obvious newbies with kid gloves because they often don't know any better. But someone with a few hundred posts to their credit? I'm going to have the expectation that they can at least perform basic tasks, like read and follow documentation written at an 8th grade level. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139207 Share on other sites More sharing options...
boblan66 Posted November 24, 2010 Share Posted November 24, 2010 Nightslyer; I agree with you. I'm just learning PHP and doing my best to overcome my physical hanicaps. 1 - I cant see very well because of a recent tear in mt retna and getting it operated on. 2 - I cannot use my left side,( hands, arm, legs) since having a stroke, so I'm typing now with only one finger. Use to type 110wpm. 3 - I learn better by example. Reading because of my eyesight is somewhat difficult. But I try all the time. So you my think, You need to read on the computer. Yes, but I can enlarge the text so I can read it. 4 - I do this to keep my mind active and to learn. I just learn a little more slowly these days. So what my seem as a easy question to some, isn't to others. I don't post anything here unless I have at least tried to fix it myself. When I become frustrated, then I post and usually it's a missing character or a typo I made. I just posted a question about the if statement. I sure hope someone doesn't think I stupid because it's easy for them! Thanks for your comments.... Bob... Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139217 Share on other sites More sharing options...
RON_ron Posted November 25, 2010 Author Share Posted November 25, 2010 How can I get the results of CODE B in seconds? I need the result of CODE B to be similar as the result in CODE A. Basically what I need is CODE B to echo in seconds. CODE A <?php date_default_timezone_set('Australia/Melbourne'); echo "time=" .time(); ?>[/code] CODE B <?php $tz = new DateTimeZone('Australia/Melbourne'); $date = new DateTime('now', $tz); echo $date->format('Y-m-d H:i:s') . "\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139304 Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2010 Share Posted November 25, 2010 Like this? $tz = new DateTimeZone('Australia/Melbourne'); $date = new DateTime('now', $tz); echo strtotime($date->format('Y-m-d H:i:s')) . "\n"; NOTE: I've merged this thread with the other thread you already had open on this subject. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139310 Share on other sites More sharing options...
RON_ron Posted November 25, 2010 Author Share Posted November 25, 2010 Thanks Pikachu2000! Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139317 Share on other sites More sharing options...
philulrich Posted November 25, 2010 Share Posted November 25, 2010 NOTE: I've merged this thread with the other thread you already had open on this subject. Maybe if the thread hadn't been hijacked, then he wouldn't have had to make another. Just sayin', you guys don't have to be douche bags 24/7. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139699 Share on other sites More sharing options...
KevinM1 Posted November 26, 2010 Share Posted November 26, 2010 Nightslyer; I agree with you. I'm just learning PHP and doing my best to overcome my physical hanicaps. 1 - I cant see very well because of a recent tear in mt retna and getting it operated on. 2 - I cannot use my left side,( hands, arm, legs) since having a stroke, so I'm typing now with only one finger. Use to type 110wpm. 3 - I learn better by example. Reading because of my eyesight is somewhat difficult. But I try all the time. So you my think, You need to read on the computer. Yes, but I can enlarge the text so I can read it. 4 - I do this to keep my mind active and to learn. I just learn a little more slowly these days. So what my seem as a easy question to some, isn't to others. I don't post anything here unless I have at least tried to fix it myself. When I become frustrated, then I post and usually it's a missing character or a typo I made. I just posted a question about the if statement. I sure hope someone doesn't think I stupid because it's easy for them! Thanks for your comments.... Bob... Hi Bob, sorry to hear about your physical limitations. I was born physically disabled myself, so I know some of what you're going through. The extra hurdles we're faced with make success taste all the sweeter. I hope you stick with PHP. It can be very rewarding. Quote Link to comment https://forums.phpfreaks.com/topic/219668-time-in-seconds/#findComment-1139716 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.