Solved

Datetime changing

Posted on 2013-01-30
4
170 Views
Last Modified: 2013-01-31
How do I get the current server datetime , add several hours and get it as datetime object?
0
Comment
Question by:yaron89
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38838725
PHP has datetime functions but not a datetime object.  Datetime values are normally stored in strings and converted as needed.  Here http://www.php.net/manual/en/function.date.php is info about the basic 'date' function and on the left are all the other date and time functions.
0
 

Author Comment

by:yaron89
ID: 38838747
I need to implement it to a datetime type for an sql table field
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 38838771
In the Example #4 date() Formatting section on that page:

$today = date("Y-m-d H:i:s");   // 2001-03-10 17:16:18 (the MySQL DATETIME format)

Open in new window

Conversion methods are also shown on that page.
0
 

Author Closing Comment

by:yaron89
ID: 38838803
$today
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
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…

777 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