Giter VIP home page Giter VIP logo

laravel-date-helpers's Introduction

laravel-date-helpers

Some custom date helpers for Laravel 4.

These helpers use the Carbon Date functions that are included with Laravel 4, but put into easier helper functions.

Installation

Place the customhelpers.php file into your app folder.

Add require app_path().'/customhelpers.php'; to your global.php file.

run composer dump-auto in terminal / CMD Prompt.

Usage

Simply type the function into your view/model/controller.

Check out the source code to see the optional parameters you can pass to these functions.

Examples

	print 'Yesterday: '.yesterday().'<br>';
	print 'Today: '.today().'<br>';
	print 'Tomorrow: '.tomorrow().'<br>';
	print 'Day Of Week: '.dayOfWeek().'<br>';
	print 'UK Date: '.ukDate('2012-01-24 00:00:00').'<br>';
	print 'UK Date / Time: '.ukDate('2012-01-24 00:00:00', true).'<br>';
	print 'Human Date: '.humanDate('2013-10-26 00:00:00').'<br>';
	print 'UK Date to Date: '.ukDateToDate('21/10/2013').'<br>';
	print 'UK Date to Timestamp: '.ukDateToDate('21/10/2013 12:00:20', true).'<br>';
	print 'Age in years: '.age('1985-10-26').'<br>';
	$weekend = weekend() ? 'Yes':'No';
	print 'Is it the weekend?: '.$weekend.'<br>';
	print 'Diff In Days: '.diffInDays('2012-01-24 00:00:00').'<br>';
	print 'Add 2 years: '.addYears(null, 2).'<br>';
	print 'Add 2 months: '.addMonths(null, 2).'<br>';
	print 'Add 2 weeks: '.addWeeks(null, 2).'<br>';
	print 'Add 2 days: '.addDays(null, 2).'<br>';
	print 'Start Of Day: '.startOfDay().'<br>';
	print 'End Of Day: '.endOfDay().'<br>';
	print 'Start Of Week: '.startOfWeek().'<br>';
	print 'End Of Week: '.endOfWeek().'<br>';
	print 'Start Of Month: '.startOfMonth().'<br>';
	print 'End Of Month: '.endOfMonth().'<br>';
	print 'Start Of Year: '.startOfYear().'<br>';
	print 'End Of Year: '.endOfYear().'<br>';
	print 'Start Of Decade: '.startOfDecade().'<br>';
	print 'End Of Decade: '.endOfDecade().'<br>';
	print 'Start Of Century: '.startOfCentury().'<br>';
	print 'End Of Century: '.endOfCentury().'<br>';
	print 'Next Monday: '.nextDay(null, 'Monday').'<br>';
	print 'Next Monday After Date: '.nextDay('2014-03-01 12:30:12','Monday').'<br>';
	print 'Next Monday After Date in d/m/Y H:ia format: '.nextDay('2014-03-01 12:30:12','Monday', 'd/m/Y H:ia').'<br>';
	```

laravel-date-helpers's People

Contributors

adamkearsley avatar

Stargazers

akbarwibawa avatar Youchen Lee (isacl) avatar  avatar Pedro Costa avatar

Watchers

James Cloos avatar akbarwibawa avatar Marcin Mucha avatar  avatar

laravel-date-helpers's Issues

Parameter switch

Doesn't it make more sense if helper functions like addDays() and such have the first parameter, in this case, for adding days instead of the format.

An idea; globalize the format so it can be automatically used if one has set it, probably in a small config file.

Not trying to kill just trying to help :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.