Convert Unix Timestamp to Time in JavaScript

Smita Kapse
Updated on 18-Jun-2020 12:14:03

243 Views

To convert a Unix timestamp to time, you can try to run the following code in JavaScript −ExampleLive Demo           JavaScript Dates                        var unix_time = 1514791901 ;          var date = new Date(unix_time*1000);          // get hours          var hrs = date.getHours();          // get minutes          var min = "0" + date.getMinutes();          // get seconds          var sec = "0" + date.getSeconds();          document.write("Time- "+hrs + ":" + min.substr(-2) + ":" + sec.substr(-2));           OutputTime- 13:01:41

Automatic Resource Management in Java

Samual Sam
Updated on 18-Jun-2020 12:13:37

882 Views

automatic resource management or try-with-resources is a new exception handling mechanism that was introduced in Java 7, which automatically closes the resources used within the try-catch block.ResourceA resource is an object which is required to be closed once our program finishes. For example, a file is read, database connection and so on.UsageTo use the try-with-resources statement, you simply need to declare the required resources within the parenthesis, and the created resource will be closed automatically at the end of the block. Following is the syntax of the try-with-resources statement.Syntaxtry(FileReader fr = new FileReader("file path")) {        // use the resource ... Read More

Create JavaScript Date Object from Date String

Nitya Raut
Updated on 18-Jun-2020 12:13:04

300 Views

To create a date object from date string, just add the string like this −var date = new Date(2018,1,1);ExampleYou can try to run the following code to create date object from date string. Here, the month is indexed as 0 for Jan, 1 for Feb, etc in JavaScript −Live Demo           JavaScript Dates                        var date;          date = new Date(2018,0,1);          document.write("Current Date: "+date);           OutputCurrent Date: Mon Jan 01 2018 00:00:00 GMT+0530 (India Standard Time)

Bootstrap Modal Show Method

David Meador
Updated on 18-Jun-2020 12:09:37

4K+ Views

The modal(“show”) method opens a modal like below −The modal is displayed using the modal(“show”) method as shown below −$("#newModal").modal("show");Let us see an example of modal(“show”) method −ExampleLive Demo       Bootstrap Example                             #button1 {       width: 140px;       padding: 20px;       bottom: 150px;       z-index: 9999;       font-size: 15px;       position: absolute;       margin: 0 auto;     }     ... Read More

Align Flex Items Around on Different Screen Sizes in Bootstrap

Alex Onsman
Updated on 18-Jun-2020 12:00:09

199 Views

To align flex items around on different screen sizes, use the justify-content-*-around class.You can achieve the following result that justifies content on small and medium screen sizes −To implement the justify-content-*-around class in Bootstrap −ExampleLive Demo       Bootstrap Example                             Default           ANS 1       ANS 2       ANS 3         Small Screen Size           ANS 1       ANS 2       ANS 3         Medium Screen Size           ANS 1       ANS 2       ANS 3         Large Screen Size           ANS 1       ANS 2       ANS 3      

Get Current Date and Time in Seconds in JavaScript

Abhinanda Shri
Updated on 18-Jun-2020 12:00:07

699 Views

To convert time in seconds, firstly get the current time. Then, multiply the hours to 3600 and minutes to 60; rest you can see below −(hours*3600) + (min*60) + secExampleYou can try to run the following code to get the current time in seconds −Live Demo           JavaScript Get Seconds                        var dt = new Date();          var sec = dt.getSeconds();          document.write("Seconds: " + sec);          var min = dt.getMinutes();          document.write("Minutes: " + min);          var hrs = dt.getHours();          document.write("Hours: " + hrs);          var total_seconds = (hrs*3600) + (min*60) + sec;          document.write("Total seconds: " + total_seconds) ;           OutputSeconds: 35 Minutes: 37 Hours: 9 Total seconds: 34655

Style Bootstrap Card with bg-info Class

Alex Onsman
Updated on 18-Jun-2020 11:51:42

224 Views

Use the bg-info class with the card-class in Bootstrap 4 to add information in a card −Now include the card-body class in it −       Bring your Laptop for the BootCamp   Let us see an example to learn how to implement Bootstrap 4 bg-info class with the card class −ExampleLive Demo       Bootstrap Example                             Information - Event           Bring your Laptop for the BootCamp      

Bootstrap 4 Justify Content Center Class

Alex Onsman
Updated on 18-Jun-2020 11:46:54

1K+ Views

Use the justify-content-*-center class in Bootstrap 4 to center content on different screen sizes.For different screen sizes −justify-content-sm-center: Small Screen Size justify-content-md-center: Medium Screen Size justify-content-lg-center: Large Screen Size justify-content-xl-center: Extra Large Screen SizeLet us see how to implement the justify-content-*-center class −ExampleLive Demo       Bootstrap Example                             Vehicle           Car       Bike       Truck               Car       Bike       Truck               Car       Bike       Truck               Car       Bike       Truck      

Align Flex Items at the End on Different Screen Sizes in Bootstrap

Alex Onsman
Updated on 18-Jun-2020 11:27:41

998 Views

Use the .justify-content-*-end class to align flex items in the end on different screen sizes like this −For small screen size, use −justify-content-sm-endFor medium screen size, use −justify-content-md-endFor large screen size, use −justify-content-lg-endLet us see how to align flex items horizontally on small, medium and large screen sizes −ExampleLive Demo       Bootstrap Example                             Form of Tea           Black Tea       Green Tea       Indian Tea               Black Tea       Green Tea       Indian Tea               Black Tea       Green Tea       Indian Tea      

Add Left Rounded Corners to an Element in Bootstrap

Alex Onsman
Updated on 18-Jun-2020 11:23:44

150 Views

To add left rounded corners to an element like , then use the rounded-left class in Bootstarp 4.To set rounded left corners −You can try to run the following code to implement rounded-left class −ExampleLive Demo       Bootstrap Example                             .one {       width: 200px;       height: 100px;       background-color: #FFFF00;       margin: 8px;     }             Rounded Corner     We have three rectangles with left rounded corner:              

Advertisements