.net 判断日期格式yyyy-MM-dd hh:MM:ss的正则表达式

加上引用: using System.Text.RegularExpressions;

/// <summary>

/// 检查字符串是否是日期格式        /// </summary>
        /// <param name="s">2011-5-8 8:08:05</param>
        /// <returns></returns>
        public static string check(string s)
        {
            if (Regex.IsMatch(s,

"^((((1[6-9]|[2-9]\\d)\\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\\d):[0-5]?\\d:[0-5]?\\d$"))

{
                return s;
            }
            else
            {
                return "";
            }

}

.net 判断日期格式yyyy-MM-dd hh:MM:ss的正则表达式

时间: 2024-07-29 22:26:33

.net 判断日期格式yyyy-MM-dd hh:MM:ss的正则表达式的相关文章

java 日期格式转换EEE MMM dd HH:mm:ss z yyyy

SimpleDateFormat parserSDF = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.ENGLISH);Date date = parserSDF.parse("Wed Oct 16 00:00:00 CEST 2013");

Delphi 修改系统时间格式为:&#39;yyyy-MM-dd HH:mm:ss&#39;, &#39;yyyy&#39;&#39;年&#39;&#39;M&#39;&#39;月 &#39;&#39;d&#39;&#39;日&#39;&#39;&#39;

声明: //记录系统日期格式: GSysShortDate, GSysLongDate, GSysTimeFormat: string; //获取系统日期格式:procedure GetSysDateTimeFormat();//设置系统日期格式:procedure SetSysDateTimeFormat(GSysShortDate, GSysLongDate, GSysTimeFormat: string); 实现://获取系统日期格式:procedure GetSysDateTimeFor

日期时间检查(格式为:YYYY-MM-DD HH:MM:SS)

//+---------------------------------------------------  //| 日期时间检查  //| 格式为:YYYY-MM-DD HH:MM:SS  //+---------------------------------------------------  function CheckDateTime(str)  {       var reg = /^(\d+)-(\d{ 1,2 })-(\d{ 1,2 }) (\d{ 1,2 }):(\d{ 1

Oracle中把一个DateTime的字符串转化成date类型。to_date(&#39;2016/12/8 18:55:43&#39;,&#39;yyyy/MM/dd hh24:mi:ss&#39;),

Oracle中把一个DateTime或者该形态字符串转化成date类型. to_date('2016/12/8 18:55:43','yyyy/MM/dd hh24:mi:ss'), 或者: select to_date('2010-10-20 13:23:44','yyyy-mm-dd hh24:mi:ss')  from dual; 是用" /"还是" -"取决于字符串是什么结构的. date类型转换成char类型, 例子to_char(' ','yyyymmd

Linux C判断日期格式是否合法

Title:Linux C判断日期格式是否合法 --2013-10-11 11:54 #include <string.h> // strlen() , strncpy() #include <ctype.h> // isdigit() #include <stdlib.h> // atoi() #include <stdio.h> /*有效格式 2013-01-01 01:01:01 2013/11/11 11:11:11 */ int main() {

判断日期格式是否正确

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Typ

PHP 判断日期格式

function is_date($date){ $is_date=strtotime($date)?strtotime($date):false; if($is_date===false&&$date!=""){ exit('日期格式非法'); } } is_date($fromdate);

php判断日期格式是否合法

实现方法 function isDate( $dateString ) { return strtotime( date('Y-m-d', strtotime($dateString)) ) === strtotime( $dateString ); } echo $this->isDate('2014-11-19') ? 'true' : 'false'; echo '</br>'; echo $this->isDate('2014-11-32')? 'true' : 'fals

【日期格式校验】java判断字符串是否为有效的日期格式

public static boolean isValidDate(String str) { boolean convertSuccess=true; // 指定日期格式为四位年/两位月份/两位日期,注意yyyy/MM/dd区分大小写: SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm"); try { // 设置lenient为false. 否则SimpleDateFormat会比较宽松地验证日期,比如