How To Calculate Dates In Perl Using Date::Manip

Author: , September 18th, 2017

1 2 3 4 my $created_at  = ’2017-09-18T13:43:40Z’; my $marker      = DateCalc(’today’,’30 days ago’); my $cmp = Date_Cmp($created_at,$marker); if ($cmp < 0) { print "Older than marker!\n"; } else { print "Same date or later than marker\n"; } my $created_at = ’2017-09-18T13:43:40Z’; my $marker = DateCalc(‘today’,’30 days ago’); my $cmp = Date_Cmp($created_at,$marker); if […]

How To Convert UNIX Timestamps to Date using PHP CLI

Author: , August 15th, 2015

For a quick visual check to see what the human-readable date is based on a UNIX timestamp integer: php -r ‘print date(“r”,1483228799);’ php -r ‘print strtotime(“1 Jan 2015″) – 1;’

How To Calculate the Next Anniversary Date in PHP

Author: , September 12th, 2012

1 2 3 4 5 6 7 8 9 10 11 $now        = time(); $this_year  = strtotime(’1 July’); $delta      = $this_year – $now;   if ($delta > 0) {         // this year’s anniversary date is still to come, use it         $anniversary   […]

How to Calculate the Last Day of the Month in PHP

Author: , April 24th, 2012

$lastDay = date(“Y-m-t”, strtotime(“-3 months”)); $firstDay = date(“Y-m-01″, strtotime(“-3 months”));

How To Calculate The Number Of Days Between Dates In PHP

Author: , November 9th, 2011

1 2 3 4 5 date_default_timezone_set(’America/New_York’); $datetime1 = new DateTime(’2009-10-31′); $datetime2 = new DateTime(’now’); $interval = $datetime1->diff($datetime2); print $interval->format(’%a days_elapsed’); date_default_timezone_set(‘America/New_York’); $datetime1 = new DateTime(’2009-10-31′); $datetime2 = new DateTime(‘now’); $interval = $datetime1->diff($datetime2); print $interval->format(‘%a days_elapsed’); http://www.php.net/manual/en/datetime.diff.php

How To Get Last Day Of Current Month With Suffix Using PERL

Author: , May 28th, 2011

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 use Date::Manip; my @months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; my $month = $months[ (localtime)[4] ]; my $last = &UnixDate("last saturday in $month", "%B %e"); $last .= &gensuffix($last);   sub gensuffix {   […]

How To Get jQuery UI Datepicker To Insert Today’s Date

Author: , May 5th, 2011

Click HERE for the original post. 1 2 3 4 5 6 7 8 9 10 11 12 13 // remember the old function var _gotoToday = jQuery.datepicker._gotoToday; // datepicker is directly inside the jQuery object, so override that jQuery.datepicker._gotoToday = function(a){     var target = jQuery(a);     var inst = this._getInst(target[0]);   […]

How To Sync the Date and Time Between Servers

Author: , July 29th, 2010

Extremely simple way to set the date and time the same as another server: (Requires SSH access to the server that has the time you want to copy; does NOT have to be root access)