We recommend that you add the magic method _ get To The Date class.

Source: Internet
Author: User
Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn about the Date class built in recently written projects. It is very inconvenient to find that there is no _ get method.
We recommend that you add them officially.

Since there is no _ get magic method, after the class is instantiated, the following functions are useless, which is very inconvenient. /**
* Date Timestamp
* @ Var integer
* @ Access protected
*/
Protected $ date;

/**
* Time Zone
* @ Var integer
* @ Access protected
*/
Protected $ timezone;

/**
* Year
* @ Var integer
* @ Access protected
*/
Protected $ year;

/**
* Month
* @ Var integer
* @ Access protected
*/
Protected $ month;

/**
* Day
* @ Var integer
* @ Access protected
*/
Protected $ day;

/**
* Hour
* @ Var integer
* @ Access protected
*/
Protected $ hour;

/**
* Points
* @ Var integer
* @ Access protected
*/
Protected $ minute;

/**
* Seconds
* @ Var integer
* @ Access protected
*/
Protected $ second;

/**
* Number of weeks
* @ Var integer
* @ Access protected
*/
Protected $ weekday;

/**
* Complete Expression of the week
* @ Var string
* @ Access protected
*/
Protected $ cWeekday;

/**
* The number of days in a year ranges from 0 to 365.
* @ Var integer
* @ Access protected
*/
Protected $ yDay;

/**
* Complete month Representation
* @ Var string
* @ Access protected
*/
Protected $ cMonth;

/**
* Date CDATE Representation
* @ Var string
* @ Access protected
*/
Protected $ CDATE;

/**
* YMD representation of a date
* @ Var string
* @ Access protected
*/
Protected $ YMD;

/**
* Time Output Representation
* @ Var string
* @ Access protected
*/
Protected $ CTIME;
// Add _ get magic Method
// Improved Date
Public function _ get ($ name ){
Return isset ($ this-> $ name )? $ This-> $ name: null;
}
For personal ignorance, Do not spray anything inappropriate.

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.