Jump to content

Need help using DateTime Object


eldan88

Recommended Posts

Hey Guys. I am fairly new to using the DateTIme Object and  trying to familiarize myself with it.  There is two things that I am really confused about

 

First, when I try to pass it a string in the constructor like "tomorrow" it throws me a "Catchable fatal error: Object of class DateTime could not be converted to string".  Below is the code I am using


$date = new DateTime('now');
echo $date;

The second thing I am confused is how use their constants such as

const string ATOM = "Y-m-d\TH:i:sP" ;
const string COOKIE = "l, d-M-y H:i:s T" ;
const string ISO8601 = "Y-m-d\TH:i:sO" ;
 
Are they predefined?
 
Any help would be really appreciated!
Link to comment
https://forums.phpfreaks.com/topic/287529-need-help-using-datetime-object/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.