amites Posted February 2, 2008 Share Posted February 2, 2008 I have a simple question for anyone that knows it, how I can I display an "n" in a date function for example I have return date("ga \o\n l\, jS \o\f F Y ", $date_val); that returns: Tuesday, 30th o November 1999, between 12:00 am - 1:00 am with o followed by a new line rather than the word on, any ideas? Link to comment https://forums.phpfreaks.com/topic/89023-display-n-in-a-date-fucntion/ Share on other sites More sharing options...
trq Posted February 2, 2008 Share Posted February 2, 2008 You can't simply write words within the date functions format string, what exactly are you expecting to happen? Link to comment https://forums.phpfreaks.com/topic/89023-display-n-in-a-date-fucntion/#findComment-455932 Share on other sites More sharing options...
p2grace Posted February 2, 2008 Share Posted February 2, 2008 You could write two date functions and concatenate them with the word "on" in between the two. Link to comment https://forums.phpfreaks.com/topic/89023-display-n-in-a-date-fucntion/#findComment-455933 Share on other sites More sharing options...
tibberous Posted February 2, 2008 Share Posted February 2, 2008 You need to use \\n. It has to do with the fact that \ is used to treat letters as literals in the date function, but \n is already converted to a new line character in PHP. So, when you do \\n, you are sending the function \n, which is a literal n. Link to comment https://forums.phpfreaks.com/topic/89023-display-n-in-a-date-fucntion/#findComment-455955 Share on other sites More sharing options...
Barand Posted February 2, 2008 Share Posted February 2, 2008 or put the format string inside single quotes <?php echo date ('ga \o\n jS \o\f F'); // 7am on 2nd of February ?> Link to comment https://forums.phpfreaks.com/topic/89023-display-n-in-a-date-fucntion/#findComment-455978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.