Reputation: 18627
Here is date format function in PHP.
function formatMyDateNicely($strTimeString) {
return date('F j, y \a\t g:iA', strtotime($strTimeString));
}
It outputs a date akin to "April 23, 12 at 12:01PM".
However, this function, which uses double quotes, does not work.
function formatMyDateNicely($strTimeString) {
return date("F j, y \a\t g:iA", strtotime($strTimeString));
}
This function outputs a date akin to "April 23, 12 a 12:01PM".
Why does changing the type of quotes matter?
Upvotes: 0
Views: 94
Reputation: 37065
It's treating the \t
as a tab character because of the double quotes. Another alternative would be to "double escape" the t
:
return date("F j, y \a\\t g:iA", strtotime($strTimeString));
Upvotes: 2
Reputation: 799150
\t
is a tab character. Single quotes inhibit interpretation of escape sequences.
Upvotes: 6