Reputation: 755
I have a table in SQL Server 2005, and it has column period (datetime)
.
The value of the column period is 8/7/2009 12:00:00 AM
, when I query using php script it give me output Aug 7 2009 12:00AM
.
Why it's not 8/7/2009 12:00:00 AM
???
Thank you
Upvotes: 0
Views: 60
Reputation: 107766
Your question reads like this:
The value of the column period is
{ a date, year 2009 month August day 7th at 12:00 AM}
When I query using php script it give me output"Aug 7 2009 12:00AM"
, i.e. one representation of the date.
Why it's not"8/7/2009 12:00:00 AM"
, i.e. another representation of the date
A datetime represents a point in time. It is a specific concept. You are comparing two separate representations of the datetime, or in other words, two ways of formatting the datetime value as a textual string.
The issue you are trying to solve is then, "How do I format a datetime as a string in PHP"? For which the answer would be to refer to the date_format (aka DateTime::format
) function
To wit, the display specifier for 8/7/2009 12:00:00 AM
is n/j/Y h:i:s A
.
Upvotes: 3