We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,363 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

error with text in date function

Hello, am working with the date function in a php file, however the text "at" is not being rendered properly:

Initial code:

"Online reservation form submitted on " . date ("d/m/y \at\ H:i") . "\n\n" .

Rendered value:

Online reservation form submitted on 29/09/12 a30 11:52

Where instead of "at" it is becoming "a30". How to fix this?

4
Contributors
6
Replies
20 Hours
Discussion Span
7 Months Ago
Last Updated
7
Views
Question
Answered
lordrt
Posting Pro in Training
467 posts since Jul 2010
Reputation Points: 30
Solved Threads: 33
Skill Endorsements: 0

Backslash should be before the t

date ("d/m/y \a\t H:i") 
pritaeas
Posting Prodigy
Moderator
9,309 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86

I tried that but it instead worked as a "tab" space added to the resulting text

lordrt
Posting Pro in Training
467 posts since Jul 2010
Reputation Points: 30
Solved Threads: 33
Skill Endorsements: 0

a and t are format characters in the date function. If you want to use them as text (literally) you must escape each of them.

broj1
Nearly a Posting Virtuoso
1,211 posts since Jan 2011
Reputation Points: 167
Solved Threads: 164
Skill Endorsements: 13

Sorry, use: date ('d/m/y \a\t H:i') (single quotes)

pritaeas
Posting Prodigy
Moderator
9,309 posts since Jul 2006
Reputation Points: 1,178
Solved Threads: 1,465
Skill Endorsements: 86

date ('d/m/y \a\t H:i');

OR

date ('d/m/y').' at '.date('H:i');

Bachov Varghese
Junior Poster
123 posts since Sep 2011
Reputation Points: 41
Solved Threads: 29
Skill Endorsements: 3

thanks

lordrt
Posting Pro in Training
467 posts since Jul 2010
Reputation Points: 30
Solved Threads: 33
Skill Endorsements: 0
Question Answered as of 7 Months Ago by pritaeas, broj1 and Bachov Varghese

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0721 seconds using 2.74MB