Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

12 Clock?

So I'm trying to make a 12 hour clock for my info window and the closest thing I got so far is:
Code
mc.theWorld.getWorldTime()

Which that just gives me how many nanoseconds or milliseconds have passed in the world like "11947" and I have no idea how to convert that into something like "09:22AM".

Anyone got any hints or know where to look?
Java has class called Data, used like "Data date = new Date();" And then you can draw a string with date.get...
What does this have to do with griefing? This is more of a Java or just Minecraft related thing.
St. Louise is listening...

[Image: EIZRuvx.png]
I think OP is wanting the time in mine craft, not the time in real life.
The time in world is different to the time in real life, I believe. Use this for the date:
new Date()
Edit: if you want time in game I think you should divide the ticks by 20 to get the amount of time in seconds. The time is in ticks, I think, not in milliseconds nor nanoseconds.
So I figured it out, not sure if anybody wants it but its here if they do, it has three formats (First one is best) but are all basically "HH:MM:AM/PM". Variables "hour24" and "minute" are from this thread on minecraftforums.net.
Code
    public String getTime(long time){
        int hour24 = ((int)(time / 1000) + 6) % 24; //From MinecraftForums.net
        int hour12 = hour24 <= 11 ? hour24 : hour24 / 2;
        hour12 = hour12 == 0 ? 12 : hour12;
        int minute = (int)((time % 1000 * 60 / 1000)); //From MinecraftForums.net
        String ampm = hour24 <= 11 ? "AM" : "PM";

        return hour12 + ":" + (minute <= 9 ? "0" + minute : minute) + ampm; //Format one
        //return (hour12 <= 9 ? "0" + hour12 : hour12) + ":" + minute + ampm; //Format two
        //return (hour12 <= 9 ? "0" + hour12 : hour12) + ":" + (minute <= 9 ? "0" + minute : minute) + ampm; //Format three
    }
If you cant figure it out how to use it, you use it like this:
Code
getTime(mc.theWorld.getWorldTime);


Possibly Related Threads...
Thread / Author Replies Views Last Post
by StanleyMar 11, 2026 06:55 AM 0 56 Mar 11, 2026 06:55 AM
Last Post: Stanley
[Legends] by JoseMarJul 17, 2025 09:25 AM 2 114 Jul 17, 2025 09:25 AM
Last Post: Nate