Login   Register  
PHP Classes
elePHPant
Icontem

File: ind.date_functions.phtml

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ricardo Costa  >  MySQL RecordSet  >  ind.date_functions.phtml  >  Download  
File: ind.date_functions.phtml
Role: Auxiliary script
Content type: text/plain
Description: Functions to manage Date
Class: MySQL RecordSet
Manage and log query, valid SQL sentence and more
Author: By
Last change:
Date: 11 years ago
Size: 2,050 bytes
 

Contents

Class file image Download
<?php
// array com a data atual
$arr_day getdate();

// definição de variaveis
$sec $arr_day["minutes"];
$mi $arr_day["seconds"];
$hour $arr_day["hour"];
$day $arr_day["mday"];
$day_week $arr_day["wday"];
$day_week_ext $days_week[$arr_day["wday"]];
$month $arr_day["mon"];
$month_ext $month_year[$mes];
$year $arr_day["year"];

// array com os meses do ano
$month_year = array(=> "Janeiro"=> "Fevereiro"=> "Março"=> "Abril"=> "Maio"=> "Junho"=> "Julho"=> "Agosto"=> "Setembro"10 => "Outubro"11 => "Novembro"12 => "Dezembro");

// array com dias da semana
$days_week = array(=> "Domingo"=> "Segunda-feira"=> "Ter&ccedil;a-feira"=> "Quarta-feira"=> "Quinta-feira"=> "Sexta-feira"=> "S&aacute;bado");


function 
mformat($zeros,$num)
{
  for(
$i 1$i <= $zeros strlen($num); $i++) $num "0".$num;
  return 
$num;
}


function 
mno_zero($num)
{
  if (
substr($num,0,1) == "0")
    return 
substr($num,1,1);
  else
    return 
$num;
}


function 
mdia_semana($formato,$data)
{
  
$d date("w",mktime (0,0,0,mno_zero(substr($data,5,2)),mno_zero(substr($data,8,2)),substr($data,0,4)));
  
$arr_d $GLOBALS["days_week"];
  if (
$formato == "t") return $arr_d[$d]; else return $d-1;
}


function 
mdata_atual($sep)
{
  return 
$GLOBALS["year"].$sep.mformat(2,$GLOBALS["month"]).mformat(2,$sep.$GLOBALS["day"]);
}


function 
mdata_ext($data)
{
  
$arr_m $GLOBALS["month_year"];
  return 
mdia_semana("t",$data).", ".substr($data,8,2)." de ".$arr_m[date("n",mktime (0,0,0,mno_zero(substr($data,5,2)),mno_zero(substr($data,8,2)),substr($data,0,4)))]." de ".substr($data,0,4);
}


function 
mdata_br($data,$sep)
{
  if(
$data != "0000-00-00" && $data != "0000-00-00 00:00:00" && $data != "") return substr($data,8,2).$sep.substr($data,5,2).$sep.substr($data,0,4);
}


function 
mdata_mysql($data)
{
  if(
$data != "00/00/0000" && $data != "") return substr($data,6,4)."-".substr($data,3,2)."-".substr($data,0,2);
}
?>