Dans ce scénario, j'ai créé une donnée d'un employé. J'ai pris un tableau en PHP et affecté des variables et les a appelés dans smarty et créé une table avec l'aide de php. En cela, je veux calculer les jours entre D.O.j et la date actuelle. Comment puis-je calculer la différence de jours entre D.O.j et la date actuelle. Veuillez m'aider à cela.comment calculer les jours entre deux dates dans smarty
Code PHP:
<?php
include_once "../prepengine-header.php";
$users = array(
1 => array(
'id' => '00AC',
'name' => 'john',
'address' => 'California',
'email' => '[email protected]',
'dob' => '1989/10/06',
'doj' => '2014/12/04'
),
2 => array(
'id' => '00XV',
'name' => 'brad',
'address' => 'Washington',
'email' => '[email protected]',
'dob' => '1980/09/23',
'doj' => '2005/03/10'
),
3 => array(
'id' => '00UY',
'name' => 'swati',
'address' => 'Mutthiganj',
'email' => '[email protected]',
'dob' => '1990/05/04',
'doj' => '2013/01/02'
),
4 => array(
'id' => '002VC',
'name' => 'smith',
'address' => 'California',
'email' => '[email protected]',
'dob' => '1989/10/22',
'doj' => '2013/07/15'
),
5 => array(
'id' => '00RK',
'name' => 'crystal',
'address' => 'New York',
'email' => '[email protected]',
'dob' => '1991/05/28',
'doj' => '2015/01/15'
),
6 => array(
'id' => '00PC',
'name' => 'virat',
'address' => 'Vadodara',
'email' => '[email protected]',
'dob' => '1989/01/24',
'doj' => '2013/04/01'
),
);
$head[] = "Serial no.";
$head = array_merge($head, array_keys($users[1]));
$theme->assign('head', $head);
$theme->assign("table", $users);
echo($theme->fetch('smartart/p_screen5.tpl'));
?>
Code de Smarty:
<html>
<head>
<title>Screen5</title>
<style>
table,tr, th, td, thead
{
border: 2px solid #333;
}
.rwd-table
{
width: 74%;
height: 77%;
text-align: center;
}
.rwd-table {
margin: 3em 10em;
min-width: 300px;
}
th{
height: 45px;
color: #ADFF2F;
}
body {
padding: 0 3em;
font-family: Montserrat, sans-serif;
color: #444;
background: #eee;
}
.rwd-table {
background: #34495E;
color: #fff;
border-radius: .4em;
overflow: hidden;
}
tr {
border-color: lighten(#34495E, 10%);
}
</style>
</head>
<body>
<form id="data_table" name="data_table">
<table class="rwd-table">
<thead>
<{foreach from = $head key = heading item = file}>
<th><{$file|upper}></th>
<{/foreach}>
</thead>
<{foreach from = $table key = heading item = file}>
<tr>
<td><{counter}></td>
<td><{$file.id}></td>
<td><{$file.name|ucfirst}></td>
<td><{$file.address}></td>
<td><{$file.email}></td>
<td><{$file.dob}></td>
<td><{$file.doj}></td>
</tr>
<{/foreach}>
</table>
</form>
</body>
</html>
Mon apparence de table comme: https://www.screencast.com/t/IVjk6Fp46Ef
Bienvenue dans Stack Overflow. Qu'avez-vous déjà essayé de faire cela? Veuillez consulter [Combien d'effort de recherche est attendu?] (Https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users). Stack Overflow n'est pas un service de codage. Vous êtes censé *** étudier votre problème et faire une bonne tentative pour écrire le code vous-même *** avant de poster. Si vous êtes bloqué sur quelque chose de * spécifique *, revenez en arrière et incluez un [exemple minimal, complet et vérifiable] (https://stackoverflow.com/help/mcve) et un résumé de ce que vous avez essayé, afin que nous puissions vous aider. – FluffyKitten