0

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

2
  • 3
    They look the same to me. Do you not like the way the PHP script formats DateTime values? Commented May 3, 2013 at 1:49
  • Yes I Do. However, I don't have choice to reformatting it. Commented May 3, 2013 at 5:31

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I just wondering why it doesn't give me "what I see is what I get" without formatting the result query. lol... Thank Richard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.