cat_fich Posted December 20, 2009 Share Posted December 20, 2009 I was thinking in doing a Chat Box in PHP. For that I would use a form with two fields, Nick and Message, then I would store the data in a DB and show them. I have already made the code for this. In the Chat Boxes I saw there the tima/date always appears in front of the messages. I don't need the time but I'd want to send to a database field the date of the moment when the user clicks the subtim button for orientation purposes. Can someone give me an hint on how to do this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/185731-chat-box-in-php/ Share on other sites More sharing options...
teamatomic Posted December 20, 2009 Share Posted December 20, 2009 $today = date("m/d/y"); HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-980719 Share on other sites More sharing options...
nafetski Posted December 20, 2009 Share Posted December 20, 2009 If you are doing an insert on each insertion, you can just set a timestamp column on your mysql DB to use the current time whenever an insert happens. Probably the easiest/most reliable way - and then if you ever need to echo the results back you can format it however you want. The above post will work for your purpose too tho Quote Link to comment https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-980775 Share on other sites More sharing options...
cat_fich Posted December 21, 2009 Author Share Posted December 21, 2009 If you are doing an insert on each insertion, you can just set a timestamp column on your mysql DB to use the current time whenever an insert happens. Probably the easiest/most reliable way - and then if you ever need to echo the results back you can format it however you want. The above post will work for your purpose too tho I did that but I got these values instead Quote Link to comment https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-981211 Share on other sites More sharing options...
mikesta707 Posted December 21, 2009 Share Posted December 21, 2009 I'm assuming you used something like PHP's time() function, or mysql's now() function. Those give whats called a Unix Timestamp, which is the number of seconds that have elapsed since some date in 1970 (I forget the exact date.) This number seems kind of useless, but can be extremely useful. you can use date()'s optional second parameter to format the timestamp to whatever date format you want. You can use that to determine how much time is between two time stamps, etc. etc. Quote Link to comment https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-981214 Share on other sites More sharing options...
cat_fich Posted December 21, 2009 Author Share Posted December 21, 2009 I got it to work. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-981568 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.