473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Getting NOW() into PHP Variable

2
Hi

sorry if this is a really basic question but I am stumped.

I have a MySQL field holding datetime in NOW() format (e.g. 2011-06-21 18:24:27). There is code at the other end doing stuff with these dates across the site, so I want to maintain the same date format globally.

I was wondering if there was an equivalent in PHP to get this date format? I want to put that datetime into a variable before inserting it into MySQL.

I have found loads of lengthy functions to do this but I can't help thinking, since NOW() is pretty succinct, that there is an easier way.

Thanks for your help.

Ted.
Jun 22 '11 #1
2 2796
BigTed
2
Ok folks never mind, I kept searching and found this:

date("Y-m-d H:i:s") which seems to do the trick. Although, for some reason it is on a different timezone than my laptop?
Jun 22 '11 #2
Dormilich
8,658 Expert Mod 8TB
when using date() the timestamp used is the unix epoch timestamp as returned by time() (i.e. GMT).
Jun 22 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jason | last post by:
hello, i am new to PHP, so go easy. I am using the examples in the book: PHP: Your Visual Blueprint For Creating Open Source, Server Side Content In the section where they talk about...
8
by: manish | last post by:
I have created a function, it gives more readability compared to the print_r function. As of print_r, it works both for array or single variable. I just want to add in it, the opton to view the...
2
by: biner | last post by:
Hello, I have file called PARAMETRES that is used in bourne shell script to define variable. In order to do so I put a ". PARAMETRES" line and the script has acces to all the variable defined in...
14
by: pl | last post by:
Hi all, I followed the mails entitled 'How to turn a variable name into a string?' in march 2005 posts as I have a similar problem. I have to get some list variable names at some point in my...
10
by: Chuck | last post by:
Hi! Any ideas as to how I can get ride of the script error undefined variable "Exp_Month"? I am trying to get this drop down list to default to the current month as opposed to 01. Thank...
2
by: James Marshall | last post by:
Does anyone know.... In JavaScript, is there any way to get a reference to a string variable (not an object), like Perl's "\" operator? I want to be able to compare two such references and know...
5
by: Paulos | last post by:
Hi, I need to know how to get a variable name that is included in a string, eg. when I have a variable called Var1 and a string like this: "Var1". Thanks.
6
by: felicia | last post by:
Hi, I am having problem to retrieve the data value of a public variable. Below is my code: Form1 Option Explicit Public selected_entry_id As String Private Sub btnEdit_Click() ...
0
by: Elliot | last post by:
I am creating a program that performs calculations on hundreds of input variables and outputs them in thousands of output variables. Each variable is declared as an instance of the VariableType...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.