Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Question About The Date() Function In Php
leiaah
post Apr 16 2005, 01:23 AM
Post #1


Super Member
*********

Group: Members
Posts: 436
Joined: 21-January 05
From: Koronadal City, Philippines
Member No.: 3,358



Hi this is the code I've been using. This works perfectly fine with mysql but I'm having trouble with getting the exact time. It probably has something to do with time zones and countries. Is there something that I need to set to get the time right? I'm from the Philippines and we have the same time as Singapore and HongKong. Help please. Tnx. huh.gif

CODE
$date = date('H:i A, jS F Y');
Go to the top of the page
 
+Quote Post
beeseven
post Apr 16 2005, 02:31 AM
Post #2


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



One thing you can do (that I did, and it worked) is to change the offset (actually I think it's the only thing you can do). Figure out what time the server is at with just a simple date showing the hour/minute. Something like:
CODE
date("H:i")
Then, find your time (just look at a clock). Where I am, the difference is 3 hours. Then convert the difference to seconds (hours*3600). To make it change the time in the date function, add this optional parameter:
CODE
date("H:i",time()+thedifference)
OR
date("H:i",time()-thedifference) //In the case that you're behind the server, I don't know what timezone you're in
You can do a test or two with the other date things to make sure it's right.
Go to the top of the page
 
+Quote Post
mobious
post Apr 16 2005, 11:07 AM
Post #3


Advanced Member
*******

Group: Members
Posts: 113
Joined: 14-January 05
From: Philippines
Member No.: 3,271



have you ever tried this?

CODE
gmdate('H:i A, jS F Y', time());
Go to the top of the page
 
+Quote Post
beeseven
post Apr 16 2005, 05:00 PM
Post #4


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



QUOTE(mobious @ Apr 16 2005, 06:07 AM)
have you ever tried this?

CODE
gmdate('H:i A, jS F Y', time());

*


That would just return the server's time, which isn't necessarily the desired time.
Go to the top of the page
 
+Quote Post
leiaah
post Apr 18 2005, 01:01 AM
Post #5


Super Member
*********

Group: Members
Posts: 436
Joined: 21-January 05
From: Koronadal City, Philippines
Member No.: 3,358



QUOTE(beeseven @ Apr 16 2005, 10:31 AM)
One thing you can do (that I did, and it worked) is to change the offset (actually I think it's the only thing you can do). Figure out what time the server is at with just a simple date showing the hour/minute. Something like:
CODE
date("H:i")
Then, find your time (just look at a clock). Where I am, the difference is 3 hours. Then convert the difference to seconds (hours*3600). To make it change the time in the date function, add this optional parameter:
CODE
date("H:i",time()+thedifference)
OR
date("H:i",time()-thedifference) //In the case that you're behind the server, I don't know what timezone you're in
You can do a test or two with the other date things to make sure it's right.
*



Thanks beeseven! The time is plus 15 here! Very cool!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. Question For The If And Echo Function(2)
  3. Need Help With Php(2)
  4. php header() function help needed(4)
  5. How To Use A Link To Call Function In Php?(8)
  6. Include File.php?id=something(13)
  7. Adding One Day To Date(3)
  8. How To Enable Mail() Function In Php(1)
  9. Question About The Mail() Function(2)
  10. Regexp Function Preg_match_all()(0)
  11. Simple Php Calendar And Yahoo! Calendar Connection(7)
  12. Explode Function Help(1)
  13. How Good Is This Data Cleaning Function?(2)
  14. The Extract() Function(6)
  15. Error With Joomla Template(1)
  1. Display The Current Date/time(3)
  2. [php] Header Function(2)
  3. [php](simple) Using Functions To Combine Values In A Form(2)
  4. Mail() Clone(5)
  5. The Best Zip Function(1)
  6. Php Date() Problem [resolved](4)
  7. Php Explode Function Help(4)
  8. How To Check If Fsockopen Function Is Enabled?(2)
  9. Displaying Date And Time (gmt+8)(5)
  10. Arrays Outside A Function(3)
  11. Endif function?(6)
  12. Php Date()?(4)
  13. PHP Function To Add Previous and Next Page Feature(5)


 



- Lo-Fi Version Time is now: 12th October 2008 - 07:23 AM