Use Date::Parse to convert normal date string to epoch timestamp. Date::Parse provides two routines for parsing date strings into time values.
str2time(DATE [, ZONE])
str2time parses DATE and returns a unix time value, or undef upon failure. ZONE, if given, specifies the timezone to assume when parsing if the date string does not specify a timezone.
strptime(DATE [, ZONE])
strptime takes the same arguments as str2time but returns an array of values ($ss,$mm,$hh,$day,$month,$year,$zone). Elements are only defined if they could be extracted from the date string. The $zone element is the timezone offset in seconds from GMT. An empty array is returned upon failure.
Source code:
use Date::Parse;
print str2time("11/22/2016 11:50AM");
PHP date() function formats a local date and time, and returns the formatted date string. In this article, I described the simple process about how to add and subtract number of years from the current date using default PHP date() function. Add number of years in current date: (Example: adding 5 years)…
To delete all values from '@myValues' array: (But, it doesn't free the memory associated with this array) @myValues = (); To delete all values from '@myValues' array, along with recovering the used memory you must use: undef @myValues;
PHP date() function formats a local date and time, and returns the formatted date string. In this article, I described the simple process about how to add and subtract number of days from current date using default PHP date() function. Add number of days in current date: php strtotime add…
PHP date() function formats a local date and time, and returns the formatted date string. In this article, I described the simple process about how to add and subtract number of weeks from current date using default PHP date() function. Add number of weeks in current date: (Example: adding 5 weeks) <?php…
PHP date() function formats a local date & time, it returns the formatted string formatted date. In this article, I described the simple process about how to add and subtract number of months from the current date using default PHP date() function. Add number of months in current date: (Example:…
To check given Perl Hash contains a value or not: Check by fetching keys from the hash: if(keys %myhash) { print "Values exist"; } else { print "Values not exist"; } keys, in scalar context returns the number of keys in the hash. Check by using a hash in scalar…
Perl is highly advanced programming language in order to process with strings. In this article, I have explained about the simplest way to split the key value pair string to Perl hash. Source code for split key value pair string to hash use warnings; use strict; use Data::Dumper; ### Sample input…
Use 'instmodsh' command to get a complete list of installed Perl modules on your Linux system and it provides an interactive shell type interface to query details of locally installed Perl modules. Open your terminal and type the following command: instmodsh Now, you will get the list of available commands…
How to move a file in Perl? Methods “move” or “mv” implemented in the module “File::Copy” can be used. Both are able to move a file to a different filesystem or disk, by first making a copy, and then deleting the original file. The different between them is in that…
The 'strtotime()' function parses an English textual datetime into a Unix timestamp and it is quite powerful with relative time format. Example: ### To get sunday timestamp of current week strtotime('sunday this week'); ### To get monday timestamp of current week strtotime('monday this week');