convertDate is an important and useful function as most date
functions in JavaScript and other date libraries, including this one,
expects a valid date string or date object as an argument.
convertDate can convert any date format to a valid date object or
string. It takes in three arguments, first one is the format of the date
you are passing on, second is the date and third is whether you want a
date string or object.
If you would like a date object, pass
a string "object" as the third argument, like in the third example below.
yy (required) - Full year. Eg: 2018
mm (required) - Full Month name, half month name or month number. Eg: January, Sep or 7
dd (required) - Date number. Eg: 3
hh (optional*) - Hour number. Eg: 13, 3
min (optional) - Minute number. Eg: 25
ss (optional) - Second number. Eg: 5
*Hours is optional; however, it is required if min is mentioned in the format.
Note: Formatting keys are case sensitive and shouldn't have a letter or word attached to it. Eg: ddday for 15day is invalid.Get a date in any format you like, essentially the opposite of lr.convertDate. It takes in two arguments, first the format you would like the date to be in and second which is optional, a specific date that needs to be a valid date string or object.
{yy}- Full year. Eg: 2018
{mm}- Month number. Eg: 12
{fm}- Full month name. Eg: February
{sm}- Short month name. Eg: May
{dd}- Day number. Eg: 5
{dn}- Day name. Eg: Tuesday
{dsn}- Short day name. Eg: Fri
{hh}- 24 Hour number. Eg: 13
{12hh}- 12 Hour number. Eg: 1
{AMPM}- Meridiem in upper case. Eg: PM
{ampm}- Meridiem in lower case. Eg: pm
{min}- Minute number. Eg: 56
{ss}- Second number. Eg: 12
Get date and time of any time zone. The function takes one argument, which is the time zone ID of the time offset.
Time offsets:
Code | Offset |
---|---|
UTC (Universal Time Coordinated) | +0:00 |
ECT (European Central Time) | +1:00 |
EET, ART (Eastern European Time, (Arabic) Egypt Standard Time) | +2:00 |
EAT (East Africa Time) | +3:00 |
MET (Middle European Time) | +3:30 |
NET (Near East Time) | +4:00 |
PLT (Pakistan Lahore Time) | +5:00 |
IST (Indian Standard Time) | +5:30 |
BST (Bangladesh Standard Time) | +6:00 |
VST (Vietnam Standard Time) | +7:00 |
CTT (China Taiwan Time) | +8:00 |
JST (Japan Standard Time) | +9:00 |
ACT (Australia Central Time) | +9:30 |
AET (Australia Eastern Time) | +10:00 |
SST (Solomon Standard Time) | +11:00 |
NST (New Zealand Standard Time) | +12:00 |
MIT (Midway Islands Time) | -11:00 |
HST (Hawaii Standard Time) | -10:00 |
AST (Alaska Standard Time) | -9:00 |
PST (Pacific Standard Time) | -8:00 |
PNT, MST (Phoenix Standard Time, Mountain Standard Time) | -7:00 |
CST (Central Standard Time) | -6:00 |
EST, IET (Eastern Standard Time, Indiana Eastern Standard Time) | -5:00 |
PRT (Puerto Rico and US Virgin Islands Time) | -4:00 |
CNT (Canada Newfoundland Time) | -5:00 |
AGT, BET (Argentina Standard Time, Brazil Eastern Time) | -3:00 |
CAT (entral African Time) | -1:00 |
If you know the time offset or want to know the time zone ID of any device use lr.getCC
Convert time from one country's / time zone's to another country's / time zone's time. The function takes in three arguments, first one is the initial time zone ID, second is the time zone ID you want to convert to, third is the date and time that needs to be a valid date string or object.
Get date and time of any time zone. The function takes one argument, which is the time zone ID of the time offset.
Adds specified parameters to date. The function takes two arguments, first is by how much you want to move the date forward to, second is the date, second argument is optional. If a second argument is not provided it will use current date.
Days- Eg: 5 Days or 1 Day
Months-Eg: 2 Months
Years- Eg: 4 Years
Name of day- Eg: Wednesday
Hours- Eg: 5 Hours
Minutes-Eg: 2 Minutes
Seconds- Eg: 4 Seconds
Subtracts specified parameters to date. The function takes two arguments, first is by how much you want to move the date back to, second is the date, second argument is optional. If a second argument is not provided it will use current date.
Days- Eg: 5 Days or 1 Day
Months-Eg: 2 Months
Years- Eg: 4 Years
Name of day- Eg: Wednesday
Hours- Eg: 5 Hours
Minutes-Eg: 2 Minutes
Seconds- Eg: 4 Seconds
Finds difference between two dates (Leap Year Included). The functions takes three parameters, first the date you want in the L.H.S, second the date you want in the R.H.S, third argument is if you want time too.
Pass string "long" in the third parameter if you want hours, minutes and seconds