Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/185731-chat-box-in-php/
Share on other sites

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 :)

Link to comment
https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-980775
Share on other sites

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

 

30007031.jpg

Link to comment
https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-981211
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/185731-chat-box-in-php/#findComment-981214
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.