Solved

Datetime changing

Posted on 2013-01-30
4
169 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP/Magento not logging 2 35
change password links 7 73
Form Processing in PHP 11 31
Crazy text will not be removed no matter what I try! 13 12
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now