Skip to content

Instantly share code, notes, and snippets.

@emulsion-io
Created April 7, 2014 07:53
Show Gist options
  • Save emulsion-io/10016294 to your computer and use it in GitHub Desktop.
Save emulsion-io/10016294 to your computer and use it in GitHub Desktop.
Bool des jours de semaine et week-end pour CodeIgniter Helper
<?php
if ( ! function_exists('isLundi'))
{
function isLundi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 1);
}
return (date('N', strtotime($date)) == 1);
}
}
if ( ! function_exists('isMardi'))
{
function isMardi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 2);
}
return (date('N', strtotime($date)) == 1);
}
}
if ( ! function_exists('isMercredi'))
{
function isMercredi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 3);
}
return (date('N', strtotime($date)) == 1);
}
}
if ( ! function_exists('isJeudi'))
{
function isJeudi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 4);
}
return (date('N', strtotime($date)) == 1);
}
}
if ( ! function_exists('isVendredi'))
{
function isVendredi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 5);
}
return (date('N', strtotime($date)) == 1);
}
}
if ( ! function_exists('isSamedi'))
{
function isSamedi($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 6);
}
return (date('N', strtotime($date)) == 1);
}
}
if ( ! function_exists('isDimanche'))
{
function isDimanche($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) == 7);
}
return (date('N', strtotime($date)) == 1);
}
}
if ( ! function_exists('isWeekend'))
{
function isWeekend($date = FALSE) {
if($date === FALSE)
{
return (date('N', strtotime(date("Y-m-d H:i:s"))) >= 6);
}
return (date('N', strtotime($date)) >= 6);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment