How do I use .toLocaleTimeString() without displaying seconds?

I’m currently attempting to display the user’s time without displaying the seconds. Is there a way I can do this using Javascript’s .toLocaleTimeString()? Doing something like this: var date = new Date(); var string = date.toLocaleTimeString(); will display the user’s time with every unit, e.g. currently it displays 3:39:15 PM. Am I able to display … Read more

Python datetime – setting fixed hour and minute after using strptime to get day,month,year

I’ve successfully converted something of 26 Sep 2012 format to 26-09-2012 using: datetime.strptime(request.POST[‘sample_date’],’%d %b %Y’) However, I don’t know how to set the hour and minute of something like the above to 11:59. Does anyone know how to do this? Note, this can be a future date or any random one, not just the current … Read more

System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()

In Java, what are the performance and resource implications of using System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime() As I understand it, System.currentTimeMillis() is the most efficient. However, in most applications, that long value would need to be converted to a Date or some similar object to do anything meaningful to humans. 8 Answers 8