Friday, October 17, 2025
HomeLanguagesJavascriptp5.js second() function

p5.js second() function

The second() function in p5.js is used to return the current second of the system clock. The value of second() function lies between 0 to 59.

Syntax:

second()

Parameters: The function does not accept any parameter.

Return Value: This function returns an integer value which represents the current second.

Below program illustrates the second() function in p5.js:

Example: This example uses second() function to return the current second.




function setup() {
  
    // Create Canvas of size 270*80
    createCanvas(270, 80);
}
  
function draw() {
      
    // Set the background color
    background(220);
      
    // Store value of second() function
    // to the variable
    let s = second();
      
    // Set the font size
    textSize(16);
      
    // Set the font color
    fill(color('red'));
      
    // Display result 
    text("Current Second is : " + s, 50, 30);
}


Output:

Reference: https://p5js.org/reference/#/p5/second

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS