Posts Tagged ‘date’

Setting a culture to an application

Wednesday, January 13th, 2010

To set a Culture (date format, decimal symbol, etc.) simply insert this code to the beginning of the application:

System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(“en-GB”)

Remember, if you have a multi-threading application, you must insert this line at the beginning of every thread.

Get the name of the month in vb.net in any language

Friday, December 11th, 2009

If you want to get the name of a month in a specific language, you should try this code:

Dim myDTFI As Globalization.DateTimeFormatInfo = New Globalization.CultureInfo(“ro-RO”, True).DateTimeFormat
Console.Write(myDTFI.GetMonthName(2))

myDTFI.GetMonthName(2) will be “februarie”. Hope this helps you.

How to validate a date format (dd/mm/yyyy hh:mm) in JavaScript

Tuesday, October 6th, 2009

<script type=”text/javascript” language=”javascript”>
function fTestDateTime(field) {
rx = /^((((31\/(0?[13578]|1[02]))|((29|30)\/(0?[1,3-9]|1[0-2])))\/(1[6-9]|[2-9]\d)?\d{2})|(29\/0?2\/(((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))|(0?[1-9]|1\d|2[0-8])\/((0?[1-9])|(1[0-2]))\/((1[6-9]|[2-9]\d)?\d{2})) (20|21|22|23|[0-1]?\d):[0-5]?\d$/

r  = rx.test(field);

return r;
}

function fCheckCondition() {
var field=document.getElementById(“your input id”).value;
if (fTestDateTime(field)==false){
alert(‘Please insert the date as dd/mm/yyyy hh:mm’);
//return false;
} else {
document.save.submit();
//return true;
}
}
</script>