Solved

getting the pc time and date to put in db

Posted on 2008-10-26
8
312 Views
Last Modified: 2013-12-13
Hi,

I have a mysql db on the site server, and add/update it thru a php webpage, two of the db fields are time related, I put the 'datetime' for the type, but it becomes cumbersome to each time insert yyyy-mm-dd hh:mm, so I'd like to just click on a button, and get the date and time from the pc which I input the data, to fill the related form field.

How can I do that?

Thank you
0
Comment
Question by:keneso
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 8

Expert Comment

by:MatthiasVance
ID: 22808900
You could use JavaScript to fill in the form field. Just use the Date class.

Kind regards,

Matthias Vance
0
 
LVL 1

Expert Comment

by:Bolter99
ID: 22809557
you can use "UNIX_TIMESTAMP()" in your mysql query.

Example:
INSERT INTO tbl_name (timestamp) VALUES (UNIX_TIMESTAMP());

When you re-call the data then use the date() function in php to convert it to a date.
0
 
LVL 7

Author Comment

by:keneso
ID: 22812527
Thank you both.
I think I should have asked for the code snippet, I had thought about the javascript, but don't know how to do it.
0
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 
LVL 7

Author Comment

by:keneso
ID: 22812621
Would this work?

<script type="text/javascript">

document.write(Date());

</script>
0
 
LVL 7

Author Comment

by:keneso
ID: 22812693
I've put the above in the head of the page, and it does show the time, date, and bunch of info on DST, which I don't need BTW.

How do I put it in the form as a button to click to fill the field?
0
 
LVL 7

Accepted Solution

by:
keneso earned 0 total points
ID: 22813146
0
 
LVL 1

Expert Comment

by:Bolter99
ID: 22816984
What format do you want the date to display? DD-MM-YY 00:00 ?
0
 
LVL 7

Author Comment

by:keneso
ID: 22821701
>>DD-MM-YY 00:00 ?

Yes that would be fine.
Please note I have found what does work, though a little overkill, hence I am wiling to give the poinks if I get a simpler, and most important full working code.

Thank you.
0

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question