// Obtain the day of the week (1-7) Function GetWeek ($ times) { $ Res = date ('w', strtotime ($ times )); If ($ res = 0) $ Res = 7; Return $ res; } // Obtain the current day's time Function GetTime ($ times) { $ Res = date ('H: I ', strtotime ($ times )); Return $ res; } // Obtain the time of the current month Function GetMonth ($ Month, $ type = 'l ') { If (! Strcmp ($ type, 'B ')) $ Res = date ("Y-m-d H: I: s", strtotime ("-$ Month months ")); If (! Strcmp ($ type, 'L ')) $ Res = date ("Y-m-d H: I: s", strtotime ("+ $ Month months ")); Return $ res; } // Obtain the current time Function GetCurrentDateTime () { $ Res = date ("Y-m-d H: I: s", time ()); Return $ res; } // Obtain the time before or after the current time Function GetDiffHours ($ hours, $ type = 'l ') { If (! Strcmp ($ type, 'B ')) $ Res = date ("Y-m-d H: I: s", strtotime ("-$ hours hour ")); If (! Strcmp ($ type, 'L ')) $ Res = date ("Y-m-d H: I: s", strtotime ("+ $ hours hour ")); Return $ res; } // Interval several minutes before or after Function GetDiffMinute ($ Minute, $ type = 'l ') { If (! Strcmp ($ type, 'B ')) $ Res = date ("Y-m-d H: I: s", strtotime ("-$ Minute minute ")); If (! Strcmp ($ type, 'L ')) $ Res = date ("Y-m-d H: I: s", strtotime ("+ $ Minute minute ")); Return $ res; } // Time before or after several seconds Function GetDiffSec ($ sec, $ type = 'l ') { If (! Strcmp ($ type, 'B ')) $ Res = date ("Y-m-d H: I: s", strtotime ("-$ sec second ")); If (! Strcmp ($ type, 'L ')) $ Res = date ("Y-m-d H: I: s", strtotime ("+ $ sec second ")); Return $ res; } // Interval of several weeks before or after Function GetDiffWeek ($ Week, $ type = 'l ') { If (! Strcmp ($ type, 'B ')) $ Res = date ("Y-m-d H: I: s", strtotime ("-$ Week week ")); If (! Strcmp ($ type, 'L ')) $ Res = date ("Y-m-d H: I: s", strtotime ("+ $ Week week ")); Return $ res; } // Interval between several days Function GetDiffDays ($ days, $ type = 'l ') { If (! Strcmp ($ type, 'B ')) $ Res = date ("Y-m-d H: I: s", strtotime ("-$ days day ")); If (! Strcmp ($ type, 'L ')) $ Res = date ("Y-m-d H: I: s", strtotime ("+ $ days day ")); Return $ res; } // Interval of several years before or after Function GetDiffYears ($ year, $ type = 'l ') { If (! Strcmp ($ type, 'B ')) $ Res = date ("Y-m-d H: I: s", strtotime ("-$ year ")); If (! Strcmp ($ type, 'L ')) $ Res = date ("Y-m-d H: I: s", strtotime ("+ $ year ")); Return $ res; } |