0

I tried to get the date with this constant, but instead of something like

Monday, 15-Aug-05 15:52:01 UTC

I get

MonAMPDTE_RJulyC850.

So it doesn't return a String but a Datetime or something, but then why does

$date = date('l, d-M-y H:i:s T');

Return exactly what I wanted (f.e.:Monday, 15-Aug-05 15:52:01 UTC)?

I'm just wondering why it returns different types on same input, because
DATE_RFC850 is just a string too: const string RFC850 = "l, d-M-y H:i:s T".

jh314
  • 27,144
  • 16
  • 62
  • 82
Big_Chair
  • 2,781
  • 3
  • 31
  • 58

3 Answers3

5

To use a constant, don't use quotes:

date(DATE_RFC850);

instead of

date('DATE_RFC850');
Bart Friederichs
  • 33,050
  • 15
  • 95
  • 195
1

RTM: http://php.net/date lists the acceptable formatting characters for a date. DATE_RFC850 is not a valid formatting "string", except when considered as its individual components:

D - Mon-Sun
A - AM/PM
T - timezone, e.g. CST
E - not a valid char, used as literal output
_ - not a valid char, used as literal output
etc...

'DATE_RFC850' is a STRING. You want the constant, e.g.

echo date(DATE_RFC850); // note the lack of ' quotes

which does output your expected format:

Monday, 08-Jul-13 09:00:29 CST
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Marc B
  • 356,200
  • 43
  • 426
  • 500
0

Use the below code,

<?php
echo date(DATE_RFC850); // you dont have to put it in quotes
?>

Output

Monday, 08-Jul-13 20:32:29 IST