-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.php
63 lines (55 loc) · 1.51 KB
/
utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/*============================================================
UTILITY FUNCTIONS
============================================================*/
function formatDate($from,$to, $date){
if ($from=='mm-dd-yyyy'){
if(preg_match('/^(..)-(..)-(....)$/', $date, $match)){
$month = $match[1];
$day = $match[2];
$year = $match[3];
}
}else{$month='';$day='';$year='';}
if ($from=='dd.mm.yyyy'){
if(preg_match('/^(..).(..).(....)$/', $date, $match)){
$day = $match[1];
$month = $match[2];
$year = $match[3];
}
}else{$month='';$day='';$year='';}
if ($from=='dd/mm/yyyy'){
if(preg_match('/^(..)\/(..)\/(....)$/', $date, $match)){
$day = $match[1];
$month = $match[2];
$year = $match[3];
}
}else{$month='';$day='';$year='';}
if($to=='yyyy-mm-dd'){
return $year.'-'.$month.'-'.$day;
}
}
function formatImporto($importo){
$posizionevirgola=strpos($importo, '.');
$lunghezza= strlen($importo);
//echo $importo.'//////'.$posizionevirgola."***".$lunghezza.'==='.($lunghezza*1-$posizionevirgola*1)."\n";
if($posizionevirgola===false){
return $importo=$importo.'.00';
}
if(($lunghezza*1-$posizionevirgola*1)<3){
return $importo=$importo.'0';
}
return $importo;
}
function comma2dot($str){
return str_replace(',', '.', $str);
}
function dot2comma($str){
return str_replace('.', ',', $str);
}
function markFileReadOnly($fileUrl){
chmod( $files, '0600');
}
function markFileReadAndWrite($fileUrl){
chmod( $files, '0755');
}
?>