Jump to content

Date and Time

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
zeroradius

zeroradius

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,406 posts
Hey guys,

I Wan't to insert the date and time into my database when some one makes a new post and then I plan to write a simple script that eaither adds or subtracts from date and time to make them acurate depending on the time zone they are in. I think Current_Timestamp inserts the time stamp from the users computer which would really screw up the times. What can I use to make the time equivilent to what time is on the server . It would be ideal to have the date and the time in two diffrent fileds but not a nesesity.
Posted Image

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I would store the time in GMT, and let the users enter their offset from GMT (I'm -5).
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,298 posts
MySQL is what I'm talking about here.

CURRENT_TIMESTAMP is an setting on a field, and and gives the time on row insertion.

a field can have a type TIMESTAMP, which is updated to current time on each change/update etc.

to set current date and time, there are functions CURDATE(), CURTIME() and CURRENT_DATETIME() to be used within the queries. ther eis also the possibility to use UNIX_TIMESTAMP() if you want the unixstyle timestamp.

all these functions uses the server time, and not the user time.