0

I'd like to get the timezone of a time, which the same time as the local time, but in an other GMT territory.

There's what i thought will work:

ceil((strtotime($scores[$i]['date'].' '.$scores[$i]['time'])-strtotime(date('d F Y H:i',strtotime("-2 hours"))))/3600)

but it gives me -26, and -22, ect..

Link to the test site, for test datas: [LINK DELETED]

Thank you for your help.

mark0ba
  • 27
  • 5
  • It'd be helpful if you showed what the input values are. Some randomish timestamps are useless. Things like nesting strtotime() calls is **NOT** a good sign. timestamp->string->timestamp is a useless waste of cpu cycles. – Marc B Aug 06 '12 at 01:37
  • @MarcB that's not random, these dates are in a DB. The server's GMT is +2 (i've updated the file on FTP, reload the link please) – mark0ba Aug 06 '12 at 01:42
  • they are random to us - obviously the numbers come out as bad timezones, but since we can't see where those time values come from, we can't help you fix the actual problem. you're asking us to slap a fresh coat of paint on a rotten house, ignoring the fact that the house is rotten. – Marc B Aug 06 '12 at 01:43
  • @MarcB it comes from a DB, and now you can see the date what i see, if you refresh the http://golvago.hu/cron.php site. – mark0ba Aug 06 '12 at 01:44
  • @MarcB Am i answered to your question? :) – mark0ba Aug 06 '12 at 01:53
  • Consider using [`DateTime`](http://php.net/manual/en/book.datetime.php) instead – Alvin Wong Aug 06 '12 at 02:00
  • What does "another GMT territory" mean? GMT is one timezone, there's not another GMT. And "The server's GMT is +2" doesn't make sense, do you mean the server's timezone is GMT+2? – Barmar Aug 06 '12 at 02:10

1 Answers1

0

I've found the logic of this, but i don't know why is that doing this, but now, it works fine...

The code:

if(ceil((strtotime($scores[$i]['date'].' '.$scores[$i]['time'])-strtotime(date('d F Y H:i',strtotime("-2 hours"))))/3600)<-12){

echo (ceil((strtotime($scores[$i]['date'].' '.$scores[$i]['time'])-strtotime(date('d F Y H:i',strtotime("-2 hours"))))/3600))+24;

}else{

echo ceil((strtotime($scores[$i]['date'].' '.$scores[$i]['time'])-strtotime(date('d F Y H:i',strtotime("-2 hours"))))/3600); }

:)

Community
  • 1
  • 1
mark0ba
  • 27
  • 5