Getting Hour and Minute in PHP
print date(‘H:i’); $var = date(‘H:i’); Should do it, for the current time. Use a lower case h for 12 hour clock instead of 24 hour. More date time formats listed here.
print date(‘H:i’); $var = date(‘H:i’); Should do it, for the current time. Use a lower case h for 12 hour clock instead of 24 hour. More date time formats listed here.
Since version v0.13.0 (January 3, 2014) of Pandas you can use the date_format parameter of the to_csv method: df.to_csv(filename, date_format=”%Y%m%d”)
You could use a try/except block: try: timestamp = datetime.strptime(date_string, ‘%Y-%m-%d %H:%M:%S.%f’) except ValueError: timestamp = datetime.strptime(date_string, ‘%Y-%m-%d %H:%M:%S’)
All you have to do is apply the format you want in the html helper call, ie. @Html.TextBoxFor(m => m.RegistrationDate, “{0:dd/MM/yyyy}”) You don’t need to provide the date format in the model class.
You can create your own custom validation method using the addMethod function. Say you wanted to validate “dd/mm/yyyy”: $.validator.addMethod( “australianDate”, function(value, element) { // put your own logic here, this is just a (crappy) example return value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/); }, “Please enter a date in the format dd/mm/yyyy.” ); And then on your form add: $(‘#myForm’) .validate({ … Read more
To get the current time in UTC in Python 3.2+: >>> from datetime import datetime, timezone >>> datetime.now(timezone.utc).isoformat() ‘2015-01-27T05:57:31.399861+00:00’ To get local time in Python 3.3+: >>> from datetime import datetime, timezone >>> datetime.now(timezone.utc).astimezone().isoformat() ‘2015-01-27T06:59:17.125448+01:00’ Explanation: datetime.now(timezone.utc) produces a timezone aware datetime object in UTC time. astimezone() then changes the timezone of the datetime object, … Read more
See: Mozilla Core JavaScript Reference: Date object Mozilla Core JavaScript Reference: String.Split Code: var strDate = “03.09.1979”; var dateParts = strDate.split(“.”); var date = new Date(dateParts[2], (dateParts[1] – 1), dateParts[0]);
item.date = $filter(‘date’)(item.date, “dd/MM/yyyy”); // for conversion to string http://docs.angularjs.org/api/ng.filter:date But if you are using HTML5 type=”date” then the ISO format yyyy-MM-dd MUST be used. item.dateAsString = $filter(‘date’)(item.date, “yyyy-MM-dd”); // for type=”date” binding <input type=”date” ng-model=”item.dateAsString” value=”{{ item.dateAsString }}” pattern=”dd/MM/YYYY”/> http://www.w3.org/TR/html-markup/input.date.html NOTE: use of pattern=”” with type=”date” looks non-standard, but it appears to work in … Read more
Well, since nobody else has stepped up, I’ll write the easy code to do this: x = ms / 1000 seconds = x % 60 x /= 60 minutes = x % 60 x /= 60 hours = x % 24 x /= 24 days = x I’m just glad you stopped at days and … Read more
Object Oriented This is the recommended way. $datetime = new DateTime(‘2010-12-30 23:21:46’); echo $datetime->format(DateTime::ATOM); // Updated ISO8601 Procedural For older versions of PHP, or if you are more comfortable with procedural code. echo date(DATE_ISO8601, strtotime(‘2010-12-30 23:21:46’));