Since he and he are the same team, so I am very familiar with his "neat" approach, for his many points of view I also very much agree; but there is a very incomprehensible place is the design of the database will always avoid the use of date/time type. His approach is to set the time-dependent field to an INT (10) type, and then store it in a UNIX timestamp. And
If the date time is inconsistent, you can use Date_default_timezone_set to set the time zone:
The code is as follows
Copy Code
date_default_timezone_set (' asia/chongqing ');
//Get current time
Golang Time ProcessingRelated package "Time"
Time stampCurrent time stamp?
1 2
fmt.Println( time .Now().Unix()) # 1389058332
STR format timeCurrent format
Since he was the same team, I was very familiar with his "neat" approach, I also very much agree with his many points of view, but one of the most incomprehensible is that the design of the database will always avoid the use of date/time type. His approach is to set the time-related field to the INT (10) type and then store it with a UNIX timestamp. And I persona
In this paper, the use of PHP to implement the regular matching date and time, and time stamp conversion example, the need for friends, refer to the bar
First, a simpler and more practical code
Date Yyyy-mm-dd
$str = "; $isMatched = Preg_match ('/^\d{4} (\-|\/|.) \d{1,2}\1
To make a time stamp:DateTime format conversion to UNIX timestamp formatpublic static long Convertdatetimeint (System.DateTime time){System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime (New System.DateTime (1970, 1, 1));Return (long) (Time-starttime). TotalSeconds;}Call method: Long time = Convertdatetimei
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