Informing the IBM Community

A computer screen with many colorful lines Description automatically generated

Language Comparisons Continued …



In my previous article, I explored a range of functions and delved into how syntax varies across different programming languages.

If you haven’t had a chance to check it out yet, I highly recommend giving it a read.

You can find the article right here.

As a quick reminder, I’ll be showcasing a variety of functions and operational codes, along with their syntax, in different programming languages to help reinforce your understanding.

  • Free format RPG
  • Command Langauage (CL)
  • Node.js & Javascript
  • PHP
  • Python


The first one, and probably the most important, is how do we code a comment in the various languages.  

Question for another day, ‘Do programmers still put comments in their code?’ Um, answers on a postcard please!

RPG provides both single and multi-line comments.  The syntax for a comment in RPG is as follows.

// This is a comment


/* This is a comment over multiple lines

Get customer details


The syntax for adding a comment to CL programming is as follows.

/* My first CL program – Single Line */


Comments can be spanned across

Multiple lines



If you are using node.js or JavaScript, the syntax for the adding a comment is shown below:

// single line comment



Block coding of a comment



If you are using PHP, the syntax for the comment statement is shown below:

// single line comment



Block coding of a comment



Python supports both single-line and multi-line comments.

# this is my first python program

In Python, there is no specific syntax for multi-line comments like /* … */ as we have shown in other languages.

Instead, you can use triple-quotes (”’ or “””) to create a multi-line string and this string is often used as a multi-line comment.

While it’s not a true comment, it serves the same purpose.


This is a multi-line “comment.”

You can add comments spanning multiple lines here.



Next onto how we get the current date in different languages.


In this section we will explore how we get the current date in the various languages.


The RPG %date built in function retrieves the current date.

The syntax for RPG trimming is as follows.

Today = %date()


/* Retrieve the current date into the variable */



In JavaScript, we get the current date by using the date object.  This is shown below:

const today = new Date();


In PHP, you can get the current date using the date() function. Here’s how it is coded.

$today = date(“d-m-Y”)


A date in Python is not a data type of its own, but you can import a module named datetime to work with dates as date objects.

import datetime

today =


Onto the last function of this article, how do we get the current time in these languages?


In RPGLE free format, you can get the current time using the %TIME() built-in function. Here’s how you can obtain the current time:

CurrentTime = %TIME();


In CL programming we get the current time by retrieving a system value (QTIME)

/* Retrieve the current time */




In JavaScript, as with getting the date, we use the date object to get us the current time.

// Create a new Date object

var currentTime = new Date();

// Extract hours, minutes, and seconds

let hours = currentTime.getHours();

let minutes = currentTime.getMinutes();

let seconds = currentTime.getSeconds();

// Format the time as HH:MM:SS

let formattedTime = hours.toString().padStart(2, ‘0’) + ‘:’ +

  minutes.toString().padStart(2, ‘0’) + ‘:’ +

  seconds.toString().padStart(2, ‘0’);


To retrieve the current time in PHP, we use the date function as shown in the figure below.

// Get the current time

$current_time = date(“H:i:s”); // HH:MM:SS format


In Python, you can get the current time using the datetime module.

The coding below shows how you can obtain the current time in Python:

import datetime

# Get the current time

current_time =

# Format the current time as HH:MM:SS

formatted_time = current_time.strftime(“%H:%M:%S”)


I trust that this article has provided you with a concise glimpse into the common functions found in various programming languages.

All the examples I have written for this article, and previous ones, can be found on my companies open-source repository on GitHub, which can be found at

If you have any questions, either on this article, or anything else on the IBM i, please use the comments below, or send me a message on X (twitter) @AndyYouens

Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems with over 40 years IBM midrange development experience. 

IBM Champion

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.


4 responses to “Language Comparisons Continued …”

  1. Nice article. keep up the good work from biblio3

  2. Nice article.Keep up the good work.thanks

  3. Easier way for JS is to play around with ..toLocaleTimeString() method:

    var currentDate = new Date();
    var currentTime = currentDate.toLocaleTimeString(‘de-DE’, {hour: ‘2-digit’, minute:’2-digit’, second:’2-digit’, hourcycle:’h23′})

    => 10:22:23

    1. Thank you for your comment and showing us a different way to acheive this.

      It goes to show there are many ways to get to the same result.

      Again, thanks for taking the time to show us this.

Leave a Reply

Your email address will not be published. Required fields are marked *