How to Get a Timestamp in JavaScript?

Sometimes, we want to get a timestamp in JavaScript.

In this article, we’ll look at how to get a timestamp in JavaScript.

How to Get a Timestamp in JavaScript?

To get a timestamp in JavaScript, we can use some operators and functions.

For instance, we write

+new Date();
new Date().getTime();
Number(new Date())

to return the timestamp of the current datetime.

We use + before new Date() to get the timestamp of the current datetime in milliseconds.

Likewise, we use the getTime method to return the same thing.

Also, we can call Number with new Date() to return the current datetime’s timestamp

Conclusion

To get a timestamp in JavaScript, we can use some operators and functions.

How to access an array/object with PHP?

Sometimes, we want to access an array/object with PHP.

In this article, we’ll look at how to access an array/object with PHP.

How to access an array/object with PHP?

To access an array entry with PHP, we can use square brackets.

And to access object properties, we use the -> operator.

For instance, we write

echo $arr{0};

to print the first entry of the $arr array.

To access object properties, we use the -> operator.

For instance, we write

echo $foo->bar->property;

to print the value of the property property in the bar object that’s a property of the $foo object.

Conclusion

To access an array entry with PHP, we can use square brackets.

And to access object properties, we use the -> operator.