Jump to content

Need help using DateTime Object


Go to solution Solved by 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.