Custom date format with jQuery validation plugin

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

How to get current isoformat datetime string including the default timezone?

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

AngularJS – convert dates in controller

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)