Suggestions on how timestamp should be used

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Suggestions on how timestamp should be used

Post by raghavan20 »

Whenever it comes to storing time on the db I have the following questions
1. Is it gd to give Current_timestamp at the db field?
2. Or do I have to set the Date using php code?
3. how this date_format() function can be used?
4. Is it possible to get global timings because my hosting service is in US, they display US timing when I use current_timestamp but I am building sites for UK clients.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

1. Is it gd to give Current_timestamp at the db field?
2. Or do I have to set the Date using php code?
3. how this date_format() function can be used?
4. Is it possible to get global timings because my hosting service is in US, they display US timing when I use current_timestamp but I am building sites for UK clients.
1. I like storing unix time stamps because it lends itself to doing <> comparisons in sql. But there are ways to get around that. If you do anything with dates the first thing is almost always a comparison and thats easier done with time stamps.

2. You can use UNIX_TIMESTAMP() in mysql to generate a timestamp or NOW() to get the date.

3/4/ Read the time manual. I've never had to do time zone stuff but I know that there are ways to do that.
Post Reply